Since PECL ssh2 1.0 there is now a command ssh2_disconnect() that closes the connection.
ssh2_disconnect()