TL;DR
/exitcloses the CLI, and a doubleCtrl+Ddoes the same. The conversation survives either way:claude --resumebrings it back. But in a background session/exitonly detaches you and the session keeps working;/stopis what actually ends it.
You press Ctrl+C to close Claude Code and nothing closes. You press it again and now it does. You type /exit in a background session and the session carries on without you. That is three answers to three different questions we tend to ask with the same keys.
So before you pick a key, work out which of the three you actually want: stop what Claude is doing, leave and come back later, or end the session for good.
1. Stopping Claude is not quitting
When Claude heads the wrong way and you are staying in the session, you don't want out, you want to interrupt. That key is Esc, and it decides whether you keep or lose the work in flight, which is why it gets a tip of its own.
Ctrl+C mid-task interrupts the running operation and closes nothing. That is why Claude Code looks like it is ignoring the key. It isn't, you are asking it for something else.
2. Leaving, with the option to come back
On an empty prompt with nothing running, Ctrl+C does start closing. The first press warns you and the second one leaves:
────────────────────────────────────────────
❯
────────────────────────────────────────────
Press Ctrl+C again to exit
That line is captured from v2.1.278, not reconstructed. Ctrl+D behaves the same way and is the cleaner choice, since it carries no interrupt duty: first press warns and, per the docs, the second has to land within 800ms. With text in the prompt, Ctrl+D deletes the character after the cursor instead of quitting.
The explicit route is /exit, aliased to /quit. The v2.1.278 binary also takes both words typed bare, without the slash, plus :q, :q!, :wq and :wq!, so a vim reflex works here too. That list is verified in the binary, not in a live session.
None of this loses the conversation. The session is saved and you pick it up whenever:
claude --continue # the last conversation in this directory
claude --resume # choose from all of them
If you lose track of sessions across repos or worktrees, every door back in is here.
What quitting does throw away is your background tasks. On macOS and Linux, Claude Code cleans them up on exit, including processes that had detached from the task's own shell. If you need them alive, don't quit: background the session instead.
3. Ending the session for good
In a background session, /exit does not end it: it detaches you, and the session keeps working. The command says so itself, because its description changes with where you run it:
/exit Exit the CLI
/exit Detach from this background session (it keeps running)
To genuinely end a background session from inside it, the command is /stop.
Reference
| You want to | Command or key | What happens |
|---|---|---|
| Stop what Claude is doing | Esc or Ctrl+C mid-task |
Cancels the running operation, you stay in the session |
| Close the CLI | /exit, /quit, or bare exit / :q |
Closes it; the conversation stays saved |
| Close it from the keyboard | Ctrl+D twice (or Ctrl+C twice on an empty prompt) |
First press warns, second one exits |
| Get the conversation back | claude --continue or claude --resume |
Picks the session up where you left it |
| End a background session | /stop |
/exit only detaches you and the session keeps running |
Official docs: Interactive mode