def METHOD_NAME(self):
    """Signal the handler to close.
    The handler will be closed after the existing
    pending message are sent to the peer.
    """
    if not self._pending_write:
        self.close()
    else:
        self._signal_close = True