def close(self):
        """Closes the connection.

        All outstanding futures for replies will be sent a DisconnectError.
        """
        if self._recv_task:
            self._recv_task.cancel()

        self._disable_monitoring()

        if self._monitor_task and not self._monitor_task.done():
            self._monitor_task.cancel()

        self._receiver.cancel()
        self._socket.close(linger=0)

        self._msg_router.fail_all(DisconnectError())
Closes the connection.

        All outstanding futures for replies will be sent a DisconnectError.