[FEATURE] Optional "Are you sure?" confirmation when closing the desktop app / exiting while the agent is working
Feature request
An optional "Are you sure you want to exit?" confirmation when closing Claude Code — ideally shown only while a session has work in progress. It could be off by default and enabled via a setting (e.g. confirmOnExit: true in settings.json), so it adds zero friction for people who don't want it.
Problem
It's too easy to close Claude Code by mistake and not notice. When that happens mid-task, the agent stops and no progress is made — and because nothing signals that the app was closed, you only discover it later when you come back expecting results and find none.
The existing protections don't cover this case:
- The double-press-within-800ms guard on
Ctrl+D/Ctrl+Chelps in the CLI, but closing the desktop app window (or the terminal window hosting the CLI) has no guard at all. - Session persistence/resume (
claude --continue, the desktop Sessions list) means nothing is lost, but it doesn't help with the real cost: the silent gap where you believed work was progressing and it wasn't. - Backgrounding tasks isn't a substitute — some of us specifically want to keep the session visible and watch progress, not detach it.
Proposed behavior
- When the user closes the desktop app window (or exits the CLI) while the agent is actively working, show a simple confirmation dialog: "Claude is still working — are you sure you want to exit?"
- Make it configurable: a settings toggle (off or on by default, your call) so users who prefer instant exit keep it.
- Even a minimal version (confirm only when a turn is in flight) would solve the main pain.
Related
#64975 and #78945 ask for the same protection for double Ctrl+C in the CLI. This request extends it to the case those can't cover: closing the desktop app window (or the terminal window hosting the CLI), where no keypress guard applies at all.
Environment
- Windows 11 Pro, Claude Code desktop app (also applies to CLI in a terminal)