Probably, when the first thread exits, the DESTROY
method is called for all the Net::OpenSSH objects effectively closing the connections.
Currently the module already has logic to support the case where the process is forked and the destructor is called from the child process so it shouldn't be too difficult to extend it to support the threads case as long as there is a method to detect it.
So, is there some easy way to detect when an object has been cloned in a new thread?
As a workaround, in the meantime, call the master_exited method for all Net::OpenSSH objects from every new thread.