Command reference ยท Claude Code
/stop
Stops the current background session.
Stops the running background session for good โ the process is terminated, but not deleted afterward. The command is only available while you're attached to a background session; the transcript and any worktree are preserved. If you only want to detach without ending the session, use /exit or press โ on an empty prompt. Outside the attached session, you instead stop it via Ctrl+X in the agent view or with claude stop <id> in the terminal (alias: claude kill). A stopped session can be restarted with an intact conversation using claude respawn <id>; to remove it completely, including the worktree, use claude rm <id>.
โ WHEN TO USE IT?
End a background session that's no longer needed
/stop, while attached to a background session โ the transcript and worktree are preserved.
Clean up after a completed background task
/stop, after the background agent has finished its task, to free up resources; with claude respawn <id> it can be started again later if needed.
โ WHEN NOT TO?
Only detach, but keep the session running
According to the docs, /stop ends the session for good; the log and worktree are preserved, but the work doesn't continue.
Better: /exit or โ on an empty prompt
Not (or no longer) attached to the session
According to the docs, /stop is only available while you're attached to a background session.
Better: Outside the session: press Ctrl+X in the agent view or run claude stop <id> in the terminal
SOURCES
- Claude Code docs (official) โ code.claude.com