Handle SIGTERM to allow clean shutdown