← Claude Code Hub
✦ Tip #202 Sep 19, 2026

How to quit Claude Code: the difference between leaving and stopping

Ctrl+C does not close Claude Code, it interrupts it. And the command that does close it only detaches you when the session runs in the background.

Stop, leave or end in Claude Code: Esc cancels the running operation, /exit closes the CLI and leaves the conversation saved, /stop ends a background session that /exit only detaches from

TL;DR /exit closes the CLI, and a double Ctrl+D does the same. The conversation survives either way: claude --resume brings it back. But in a background session /exit only detaches you and the session keeps working; /stop is 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

Free guide

The 51 essentials, as a guide.

One page per tip. Five chapters. What I actually use daily in production. No theory, no fluff.

  • I. Getting started 10 tips
  • II. Awareness 3 tips
  • III. Mastery 22 tips
  • IV. Autonomy 10 tips
  • V. Comparison 6 tips
Are you a professional Web developer?

You'll receive the guide by email · You join the Gravitas newsletter · Unsubscribe anytime

of 51
#

Wmedia · 51 Tips
Free guide · 51 tips · 5 chapters

The 51 essentials, as a guide.

Are you a professional Web developer? · Unsubscribe anytime
Workshop for teams

Multiply your team's output without sacrificing quality: a 6 to 8 hour AI First workshop, online, on the Claude platform.

See the workshop

Want the 51 Claude Code essentials as a guide?