Proper shutdown on SIGINT/SIGTERM/SIGHUP