Net::SSH::Any does not provide any kind of disconnect method. In order to close the connection you can, as you said, let the object go out of scope or undefine all the variables pointing to it.
Comment on Re: Explicit closing connections with Net::SSH::Any