catch SIGINT/SIGTERM and cleanly exit