Exiting gracefully from exit signals