'Clean up the connection by closing it.  The command running on the
endpoint has ended so the connection is no longer needed.
@param connection: The L{SSHConnection} to close.
@type connection: L{SSHConnection}
@param immediate: Whether to close connection immediately.
@type immediate: L{bool}.'

def cleanupConnection(self, connection, immediate):

    if immediate:
        connection.transport.transport.abortConnection()
    else:
        connection.transport.loseConnection()
