'Closes the websocket connection.
``code`` and ``reason`` are documented under
`WebSocketHandler.close`.
.. versionadded:: 3.2
.. versionchanged:: 4.0
Added the ``code`` and ``reason`` arguments.'

def close(self, code=None, reason=None):

    if (self.protocol is not None):
        self.protocol.close(code, reason)
        self.protocol = None
