When SIGINT or SIGHUP signals are sent to the remote server or Ctrl-C pressed, the server reports that it is shutting down but the process doesn't actually end. The reason is that it is still waiting in handle_request method and exits only after next request comes and that method returns.
This can be fixed by sending an exception from the signal handler to exit handle_request. This exception needs to be caught and silenced to make the exit clean.