Just tell the server to exit.

    WARNING: There are race conditions, for example with TimeoutSocket.accept.
    We don't care: the user can just rekill the process after like 1 sec. if
    the first kill did not work.

def sigterm_handler(signum, stack_frame):
    """
    Just tell the server to exit.

    WARNING: There are race conditions, for example with TimeoutSocket.accept.
    We don't care: the user can just rekill the process after like 1 sec. if
    the first kill did not work.
    """
    # pylint: disable-msg=W0613
    global _KILLED

    for name, cmd in _COMMANDS.iteritems():
        if cmd.at_stop:
            LOG.info("at_stop: %r", name)
            cmd.at_stop()

    _KILLED = True

    if _HTTP_SERVER:
        _HTTP_SERVER.kill()
        _HTTP_SERVER.server_close()