'Close the connection. Does nothing if the connection is already closed.
handler_initiated: If a handler is requesting a close versus the connection
being closed by one of the endpoints.'

def close(self, handler_initiated=True):

    if self.closed:
        return
    self.closed = True
    close_quietly(self.server_socket)
    close_quietly(self.client_socket)
    self.handler.on_close(handler_initiated)
    for handler in self.data_handlers:
        handler.on_close(handler_initiated)
