Blog · October 22, 2026 · 8 min read · by Vilva Athiban P B

How to Stop a Running Claude Code Task: Esc vs Ctrl+C, Background Tasks, Subagents, and Disconnecting Remote Control

Starting a Claude Code task is one keystroke. Stopping one turns out to have five different answers, depending on what exactly is running: a response you want to redirect, a shell command that has gone off the rails, a background task that keeps humming after the turn ended, a subagent fleet, or a session that is still showing up on your phone as “connected to your computer” hours after you thought you were done. This guide covers each one, in the order people usually hit them, using the current Claude Code documentation for the exact keys and commands. It applies to the terminal, the VS Code extension and the Desktop app, with the differences called out.

1. Stop the current response: Esc, not Ctrl+C

While Claude is writing or running a tool, press Esc. The docs describe it as “stop the current response or tool call mid-turn so you can redirect”, and the important part is what happens next: Claude keeps the work done so far, and if you had messages queued, Claude Code sends them next. Nothing is rolled back. You can type a correction and continue from where it stopped.

Ctrl+C is the blunter tool. It interrupts a running operation too, but when nothing is running, the first press clears your prompt input and a second press exits Claude Code entirely. If you only want Claude to stop talking, Esc is the key; reserve Ctrl+C for when you want out. (If you cleared a draft by accident, Up brings it back: double Esc on a non-empty prompt saves the draft to history before clearing it.)

In the Desktop app the same thing is a button. The docs: “click the stop button to interrupt immediately, or type a correction and press Enter to send it without stopping the running action”. Esc works there as well, listed as “Stop Claude’s response”.

One subtlety that catches people who queue messages while Claude works: since v2.1.281, sending a queued message while shell commands or subagents are running moves that work to the background instead of interrupting it, and Claude reads your message in the same turn. If you actually want the turn interrupted and your draft kept, press Esc; Claude Code keeps what you queued and sends it right away.

2. Stop a background task: /tasks

A Bash command that ran past its time limit, or one you pushed to the background with Ctrl+B (twice in tmux, because of the prefix key), keeps running after the turn ends. It does not stop when you press Esc, because it is no longer part of the turn. To see and stop it, run /tasks, which lists the running shells and subagents and lets you stop a task from the list. Note that Ctrl+T toggles Claude’s to-do checklist, not this view; the docs make the distinction explicitly.

Two behaviours worth knowing before you reach for kill in another terminal. First, on macOS and Linux, stopping a task from /tasks also stops processes that detached from the task’s shell, such as ones started under setsid or timeout, so you rarely need to hunt for orphans. Second, background tasks are cleaned up automatically when Claude Code exits, unless you backgrounded the session itself rather than exiting it, in which case the tasks keep running in the background session.

If you want background tasks to never start in the first place, set CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1; starting in bare mode turns them off too. The memory-pressure reaper, which stops idle background tasks when the OS reports critical memory pressure, is a separate switch covered in our post on CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP.

# See running shells and subagents, stop one from the list
/tasks

# Never background anything in this session
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 claude

3. Stop every background subagent at once: Ctrl+X Ctrl+K

When Claude has fanned out into several background subagents and you want all of them gone, there is a dedicated chord: Ctrl+X Ctrl+K. The docs describe it as “stop all running background subagents in this session, and turn off artifact auto-replies for the rest of it”; press it twice within three seconds to confirm, and it works even while a background subagent’s permission prompt is open. For stopping one subagent rather than all of them, use /tasks as above, or the subagent panel in the footer. Our subagents guide covers how foreground and background subagents differ.

4. Stop a task from your phone, or stop the phone from seeing it

This is the question behind searches like “Claude says connected to my computer, how do I make it stop”. Remote Control connects claude.ai/code or the Claude mobile app to a Claude Code session running on your machine. Two separate things can be stopped: the task, and the connection.

Stopping the task from the device

When you open a connected session from your phone or a browser, the device shows any subagents and workflows the session has running in the background. Per the docs, “stop one of them from the device, and Claude Code stops that task on your machine”. The conversation itself stays in sync, so a message sent from the phone behaves like one typed in the terminal.

Disconnecting the session

  • In an interactive terminal session that you connected with /remote-control: run /remote-control again. It opens a status panel that lets you disconnect while your local session keeps running. The /rc active indicator in the footer disappears.
  • In VS Code or the Desktop app: the same, type /remote-control again to disconnect. In Desktop you can also turn off the Remote Control switch in the Environment card of the session details panel. If the session connected automatically at startup, typing the command shows “Remote Control is already on” with a Turn off link on that line.
  • If you started a server with claude remote-control: press Ctrl+C in that terminal. The sessions it was serving stop responding from your phone, and, unless you started it with --no-create-session-in-dir, they are not archived; claude remote-control --continue brings the last one back for about four hours.
  • Closing the terminal, quitting the Desktop app or VS Code, or otherwise stopping the claude process takes the session offline too. That is the heavy-handed version of the same thing.

Stopping it from connecting in the first place

If sessions keep appearing on your phone because auto-connect is on: in the CLI, run /config and set Enable Remote Control for all sessions to false; in Desktop, turn off Settings > Claude Code > Connect new sessions to Remote Control (the docs note that if it already shows off, toggle it on and off once so Desktop saves the choice). To stop every session on the machine from connecting, including the CLI, set disableRemoteControl to true in ~/.claude/settings.json; a session that was already connected stays connected until you turn it off for that session. To make a session disappear from the lists on other devices, archive it in Desktop, which archives its Remote Control copy as well.

// ~/.claude/settings.json
{
  "disableRemoteControl": true
}

Finally, a device you no longer own: open claude.ai/settings/account, find Trusted devices, and remove it. Its credential is revoked immediately. For more on the feature itself, see the Remote Control guide and the post on turning off auto mode in Remote Control.

5. Stop a scheduled or unattended run

A headless claude -p run or a scheduled task has no prompt to press Esc in. For a -p process, Ctrl+C in its terminal, or killing the process, is the answer, and background commands in an unattended session are stopped at their time limit anyway. For Desktop scheduled tasks, the control is in the task’s own settings rather than in a session; the current run can be stopped like any other session, and the schedule itself is paused or deleted from the task list. The specifics are in our post on loops and scheduled tasks.

Which one do I need?

  • Claude is writing or running a tool and you want to redirect: Esc.
  • You want to leave Claude Code: Ctrl+C twice on an empty prompt, or Ctrl+D twice.
  • A shell command is still running after the turn: /tasks, stop it from the list.
  • Several background subagents: Ctrl+X Ctrl+K, twice to confirm.
  • Your phone still shows the session: /remote-control again, or Ctrl+C on the server.
  • Sessions keep showing up on your phone: turn off auto-connect, or set disableRemoteControl.
  • A device you do not trust any more: remove it under Trusted devices.

The pattern across all five is that Claude Code separates the conversation, the processes it spawned, and the connections to it, and gives each its own off switch. Once you know which layer you are looking at, stopping it is one key or one command.

Keep reading

Desk Exercises for Programmers: 15 Moves to Do While Your AI Agent Codes

7 min read

Exercise While Coding: Turn Claude Code Wait Time Into Micro-Workouts

7 min read

Claude Code Notch Notifications on Mac: See When Claude Is Done Without Watching the Terminal

7 min read

Claude Code Tips and Tricks: 12 Ways to Use Claude Code Effectively

8 min read

Claude Code Multiple Sessions: How to Run Agents in Parallel Without Losing Track

6 min read

A Claude Code Workflow That Doesn't Involve Watching the Terminal

5 min read

Claude Code Hooks: A Practical Guide to Automating Your Agent Workflow

7 min read

Claude Code Auto Mode: Fewer Permission Prompts Without Living Dangerously

7 min read

Claude Code Subagents: How to Delegate Work to Specialized Agents

7 min read

Claude Code Context Management: Treat the Context Window Like a Budget

6 min read

Per-Subagent Model Selection: Route the Grunt Work Down, Keep the Judgment Up Top

7 min read

Skills and Plugins: How to Teach Claude Code Your Way of Working

7 min read

Claude Code Background Tasks: Run Long Commands Without Blocking Your Session

6 min read

Codex CLI Notifications: How to Get a Ding When Codex Is Done or Needs Input

7 min read

Cursor Notification When Done: Every Way to Get Notified When Cursor Finishes

6 min read

Claude Code Notifications: How to Get Notified When Claude Code Finishes or Needs Your Input

6 min read

Want to Be Notified When Claude Responds? How Claude Notifications Work on Web, Desktop, and Mobile

5 min read

Claude Code Notification Scripts: Copy-Paste Recipes for Every Platform

6 min read

Get a Ding the Moment Codex Needs Your Response

6 min read

Get Notified the Moment Claude Code Is Waiting for Your Input

6 min read

“Notifications Are Turned Off for Claude” — Here Is the Fix

6 min read

Codex Sound When Done: Make Codex CLI Play a Sound When It Finishes

6 min read

terminal-notifier + Claude Code: Native macOS Alerts When Your Agent Finishes

6 min read

Gemini CLI Notifications: How to Get a Sound or Alert When Gemini Finishes

6 min read

Get Claude Code Notifications on Your Phone

6 min read

Claude Code Remote Control, Explained

7 min read

preferredNotifChannel: Claude Code's Built-In Notification Setting

6 min read

Claude Code Notifications in tmux and Over SSH

7 min read

Claude Code Effort Levels: Why Your Setting Keeps Getting Ignored

8 min read

Codex vs Claude Code Notifications: How Each One Tells You It Is Done

8 min read

Claude Code Notifications Not Working: A Diagnostic Checklist

10 min read

Claude Code Notifications Inside Your Editor's Terminal

7 min read

CLAUDE_CODE_DISABLE_BACKGROUND_TASKS Explained

7 min read

CLAUDE_CODE_DISABLE_BG_SHELL_PRESSURE_REAP Explained

8 min read

Cursor Alerts Explained: Every Alert Cursor Raises, and How to Control Them

7 min read

Claude Code Environment Variables: The Groups That Actually Matter

10 min read

Claude Code Notifications on WSL and Windows

9 min read

Claude Code Checkpoints and /rewind

8 min read

Claude Remote Control: How It Works, Turning It Off, and Auto Mode

7 min read

Claude Code /loop: Poll a Deploy, Babysit a PR, and Get Told When It's Done

8 min read

Setting Up NotchFit With OpenAI Codex CLI: Hooks, $notchfit-plan, and the Daily Flow

7 min read

Claude Mods Explained: What the New Plugin Layer Can Do, and How to Turn On 'You Should Know'

9 min read

NotchFit vs Mac Break Reminder Apps: A Clock or a Signal From Your Coding Agent?

8 min read

Claude Code Headless Mode: Running claude -p in Scripts and CI, and the Three Signals That It Finished

10 min read

Building a Movement Habit at a Desk: Use the Agent Run as the Cue, One Set as the Unit, and Streaks Carefully

8 min read

Claude Code MCP Servers Explained: Adding Servers, Choosing a Scope, Handling Secrets, and Why Long Tool Calls Go to the Background

10 min read

/notchfit:plan Explained: How Claude Code or Codex Writes a Weekly Workout Plan the Notch Can Actually Run

8 min read

Claude Code Spinner Verbs Explained: What “Pondering” and “Brewing” Mean, How to Change Them, and Why You Should Stop Watching the Spinner

7 min read

Why NotchFit's Done and Permission Alerts Wait Until Your Set Ends, When That Costs You, and How to Turn the Workout Off

7 min read

How to Resume a Claude Code Session: --continue vs --resume, Naming Sessions, the Session Picker, Branching, and What Comes Back

9 min read

NotchFit on a Mac Without a Notch: How Pill Mode Works on Mac mini, iMac, Mac Studio and a MacBook With the Lid Closed

6 min read

How to Run a Claude Code Session in the Background: /background, claude --bg, Agent View, and Getting Back to It

9 min read

What a Notch App Can See: NotchFit's Local-First Design, What the Claude Code and Codex Hooks Send, and What Stays on Your Mac

7 min read

Why Codex CLI Asks for Permission Every Time, and How to Tune the Sandbox and Approval Policy Without Going Full Access

8 min read

What to Do While Claude Code or Codex Works: A Simple Protocol for the Two-to-Twenty-Minute Gap in Every Agent Run

7 min read

Is It Possible to Get a Notification When Claude Code or Codex Hits a Reset? Yes for Claude Code: the quota_auto_resume Hooks, Explained

8 min read

What a MacBook Notch App Can Actually Do: The Five Kinds of Notch Utility, Their Trade-offs, and Where NotchFit Fits

7 min read

How to Make MCP Servers Not Take Up as Much Context in Claude Code: Tool Search, alwaysLoad, Scopes and Output Caps

8 min read

The notchfit Command Line: Drive Your Workout, Read Status as JSON, Validate Plans and Test the Notch Without Leaving the Terminal

7 min read

How to Audit MCP Tool Calls Made by Claude Code: A Five-Minute Hook Audit Log, OpenTelemetry Tool Events, and the Transcript for Investigations

9 min read

Exercise Snacks: What the Research Actually Says About One-Minute Vigorous Breaks, What It Does Not, and How NotchFit's Agent-Run Sets Compare

8 min read

How Long Until a Claude Code MCP Tool Call Times Out? The Four Timers (Startup, Two-Minute Backgrounding, Idle, Wall-Clock), Their Defaults, and Which One to Change

8 min read

Sitting Too Long as a Developer: The Posture Problems Coding Agents Made Worse, What the Research Says About Breaking Up Sitting, and How NotchFit Turns an Agent Run Into the Break

8 min read

Claude Code .mcp.json Explained: Where Project-Scoped MCP Servers Are Read From, What Happens in Subfolders and Monorepos, and Why a Committed Server Shows Pending Approval

8 min read

Standing Desk Exercises for Developers: Why Standing Still Is Not the Goal, Eight Movements That Fit a Thirty-Second Agent Run, and How NotchFit Cues Them From the Notch

8 min read

The claude mcp Command Reference: add Syntax by Transport, What --scope local, project and user Actually Mean, add-json and add-from-claude-desktop, list, get, remove, login and serve

9 min read

Your First Week With NotchFit: Install and Simulate, Run Real Tasks, Write a Smaller Plan Than You Want, Tune the Alerts, Survive the First Skipped Day, and Decide What Stays

8 min read

Pomodoro vs Agent-Driven Breaks: Timing Movement to Claude Code and Codex Runs Instead of a Timer

7 min read