shutting down the reactor loop cleanly with exit code