Command reference Β· Claude Code
/exit
Exits the CLI.
Exits the CLI, which also ends all background tasks running in the session, such as Bash processes or monitors β they're automatically cleaned up on exit, not continued. In an attached background session (see /background), /exit behaves differently: here the command only disconnects from the terminal, the session itself keeps running in the background. You can reattach via claude agents, or β if the session has finished in the meantime β via the /resume picker, where background sessions appear marked with bg. If you actually want to stop such a session instead of just detaching, use /stop while you're still attached. Alias: /quit.
π THE SAME TASK (βEXITβ) ON OTHER PLATFORMS
β WHEN TO USE IT?
Cleanly exit a session once the task is done
/exit after finishing the work
Deliberately only detach from a background session
/exit while attached to a background session β the session keeps running, you can reattach to it later via claude agents.
β WHEN NOT TO?
You actually want to stop an attached background session
According to the docs, /exit only disconnects in an attached background session, the session keeps running.
Better: use /stop while still attached
Running background Bash processes or monitors should keep running
According to the docs, background tasks are automatically cleaned up on exit instead of continued β only backgrounding the session hands them off to a session that keeps running.
Better: use /background instead of /exit to keep the session running in the background along with its running tasks
SOURCES
- Claude Code docs (official) β code.claude.com
MORE COMMANDS Β· Claude Code