Graceful Shutdown
Handle SIGTERM signals and shut down cleanly
CLAUDE.md
Handle SIGTERM and shut down gracefully. Stop accepting new requests, finish in-flight requests, close database connections, and flush logs before exiting. Set a timeout to force exit if cleanup takes too long.
Copy this block into your CLAUDE.md or agent config file to enforce it in your workflow.