Handle SIGTERM and SIGINT