refactor QUIT signal handler to be a graceful shutdown (e.g. wait for active messages to be handled before shutting down)