Now cleanly handles SIGTERM and SIGINT