my $ssh = Net::OpenSSH->new(...); ... undef $ssh; #### $ssh->disconnect;