claude-code·Published 2026.06.01·Views 2
Claude Code /exit: The Basics of Cleanly Ending a Session
How to cleanly end Claude Code with /exit when you finish work, including the difference that background sessions are detached, not terminated.
You've finished your work — is it fine to just close the window to shut Claude Code down? Usually there's no big problem, but there's a proper way to wrap up cleanly. That's /exit. It's a basic command worth knowing, so learning it first is a good idea.
Definition (what it is)
/exit is a command that terminates the Claude Code CLI (a program you use via commands). There's also an alias (a different name for the same feature), /quit.
One thing to remember: in a background session (work running separately behind the screen), /exit doesn't fully shut it down — it only exits (detaches) from that session.
How to use it (by difficulty)
Basic — terminate
/exit
Entering this terminates the CLI. You can also enter it using the alias as below and it works the same.
/quit
Common pitfalls (only when applicable)
- If there's a session running in the background,
/exitdoesn't stop that work — it only detaches it from the screen. The work may keep running, so if you really want to stop it, you need a separate way to halt it. - If you need to keep important conversation content before terminating, it's safer to save it first with
/export(export conversation).
Real-world example
When you finish a day's work, the single line /exit wraps it up cleanly. Proper termination is more stable than force-closing the window, so it's good to make it a wrap-up habit.
Taking it further
Knowing that a background session isn't terminated by /exit but only detached, you can also use it to keep a long task running behind the scenes while you just exit the screen.
Summary
/exit (alias /quit) is the most basic command for terminating Claude Code. Just remember the one difference: in a background session it's detachment, not full termination.
Based on Claude Code v2.1.154 (2026.05)
Comments
Comments 0
Checking sign-in status…
Loading comments…