[FEATURE] Graceful shutdown signal for headless/long-running sessions
Resolved 💬 3 comments Opened Feb 26, 2026 by dmd1214GH Closed Mar 3, 2026
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When running Claude Code headless (e.g., orchestrating via claude -p or long-running automated sessions), I want a way to request a graceful shutdown.
Proposed Solution
Requested behavior:
Some way to signal Claude Code to shut down gracefully. Equivalent to hitting <esc> to interrupt the thought and saying something like "Finish what you're doing and wrap this up, we need to stop."
- Finish or abort the current tool call
- Fire SessionEnd hooks
- Terminate all child processes it spawned (Bash tool shells, subagents)
- Exit cleanly
Alternative Solutions
Current behavior:
- SIGTERM / SIGINT kills the Claude Code process but orphans all Bash tool child processes (they get reparented to PID 1)
- SIGKILL is worse — no hooks fire at all
- SessionEnd hooks only fire on interactive exits (/exit, Ctrl+D)
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗