Skip to content

[BUG] orphaned processes from subagents crashing computer #18405

Closed as not planned

Description

@JasenNelson

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Description

Using /exit to close Claude Code while subagent tools are still running in the background causes system crashes. The /tasks command shows no active tasks, but orphaned processes remain and accumulate.

Steps to reproduce

  1. Start a long conversation that spawns subagent tasks
  2. Wait for apparent completion (no tasks shown via /tasks)
  3. Run /exit
  4. System crashes/freezes

Observed behavior

  • Multiple orphaned claude processes (10+) remain after apparent task completion
  • Large node process (~300MB+) persists - likely stuck subagent
  • /exit doesn't terminate these processes
  • Accumulated processes crash Windows

Expected behavior

  • /exit should terminate all spawned processes
  • Subagent processes should clean up when parent task completes

Environment

  • Windows 10/11
  • Claude Code version: [run claude --version]

Workaround

Manually kill processes before exiting:
Get-Process -Name "claude","node" | Stop-Process -Force

What Should Happen?

When /exit is called or a task completes, Claude Code should:

  1. Detect and terminate all spawned subagent processes
  2. Clean up any associated node processes
  3. Exit gracefully without leaving orphaned processes
  4. If processes cannot be terminated, warn the user before exiting

Error Messages/Logs

No error messages displayed - system freezes/crashes silently.

Pre-crash process state (captured via Get-Process):
- 10 orphaned `claude` processes (74MB-188MB each)
- 1 large `node` process (322MB RAM, 7.14s CPU) - likely stuck subagent
- Total: ~1.2GB RAM consumed by orphaned processes

No BSOD - Windows becomes unresponsive and requires hard reboot.
The `.claude` cache folder does not exist after crash, suggesting the issue is process accumulation rather than corrupted state files.

Steps to Reproduce

  1. Start Claude Code and begin a complex task that spawns subagent tools (e.g., multi-file edits, research tasks, or anything using parallel processing)
  2. Allow task to run to apparent completion
  3. Check /tasks - shows no active tasks
  4. Run /exit to close Claude Code
  5. System becomes unresponsive/crashes
  6. After hard reboot, orphaned processes can be observed if caught before crash:
    Get-Process | Where-Object { $_.ProcessName -match "node|claude" }

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

N/A - not confirmed as regression

Claude Code Version

2.0.76 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Activity

  1. github-actions commented on Jan 15, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. Orphaned processes after terminal close cause runaway memory consumption (34GB+ per instance) #17391
    2. [BUG] v2.0.76 on Apple Silicon: AVX warning + spawns 40+ zombie node processes causing OOM #15975
    3. [BUG] Found 30+ "2.1.1" processes in my Activity Monitor, despite having 3 Terminals open. #17219

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. JasenNelson commented on Jan 15, 2026

    @JasenNelson
    Author

    This bug is related to 3 others identified by the github-actions[bot], but has one significant difference, it's crashing my Windows 11 Pro and forcing my computer to reboot. The underlying reason of subagents using tools that get stuck in loops and don't close with subagent completion and lack of primary agent awareness or tracking (via/tasks). Literally typing /exit in Claude Code results in immediately crash of Windows and loss of anything I had open.

    The 3 other related posts provided by the bot include:
    #17391
    #15975
    #17219

  3. Muhtasham commented on Jan 17, 2026

    @Muhtasham

    Also having same issue:

    Version & Environment

    • Claude Code version: 2.1.11
    • OS: macOS 15.3 (Darwin 25.2.0) ARM64
    • CPU: Apple M4
    • Shell: fish

    Observed Behavior

    Multiple claude processes running with high CPU, some orphaned (PPID=1):
    Total: ~420% CPU from zombie claude processes.

    Expected Behavior

    When a Claude Code session terminates, all spawned background agents/subagents should be terminated via:

    • Process group signals (SIGTERM/SIGKILL to pgrp)
    • Explicit child process tracking and cleanup

    Reproduction

    1. Use Claude Code with Task tool to spawn background agents
    2. Exit the session (Ctrl+C, close terminal, etc.)
    3. Check for orphaned claude processes: ps -Ao pid,ppid,pcpu,etime,comm | grep claude
  4. alexeyv commented on Feb 25, 2026

    @alexeyv

    Additional data point: subagent persists at high CPU during a live session (macOS, v2.1.53)

    Same root cause, slightly different scenario from the original report. This happened during an active session, not after /exit.

    What happened:

    1. Parent session spawned two Task tool subagents (review agents, model: haiku and model: sonnet) for parallel file review
    2. Both agents completed their work and returned results to the parent
    3. The parent session continued working normally with the results
    4. At least one subagent process persisted as an invisible zombie at 34% CPU sustained

    Discovery: Only found it hours later via ps aux. The process:

    • Was not visible in /tasks or any UI element
    • Showed as an independent Claude process (claude --dangerously-skip-permissions --plugin-dir pan-out) under the same terminal process tree
    • Had caffeinate child processes (sleep prevention timers)
    • Was working in the parent session directory (/Users/alex/src/cooking)
    • pstree showed it under the same Ghostty terminal shell, but in no visible pane/tab

    Killing the orphan killed the parent: When the user killed this unknown process, it took down the parent Claude session too -- suggesting the subagent process was still structurally linked to the parent despite appearing independent in ps.

    Key distinction from original report: This is not about cleanup after /exit. The subagent finished its work, delivered results, and the parent kept going. The process just never terminated after completing its task.

    Environment: macOS 26.3, ARM64, Claude Code 2.1.53, Bun runtime, --dangerously-skip-permissions

  5. theQuert commented on Mar 2, 2026

    @theQuert

    Community workaround: cc-reaper

    I ran into the same orphan process accumulation issue on macOS — after several sessions, claude subagents and MCP servers pile up to 7+ GB of RAM (all with PPID=1, no controlling TTY).

    I built cc-reaper as a three-layer cleanup tool:

    1. Stop hook — automatically kills orphan processes when a session ends normally
    2. proc-janitor daemon — scans every 30s and cleans up orphans from crashed sessions (60s grace period)
    3. Shell commands — claude-ram (RAM usage report) and claude-cleanup (manual kill)

    It targets claude.*stream-json (subagents), MCP servers (mcp-server, context7, supabase, etc.), and chroma-mcp processes, using TTY filtering (awk '$7 == "??"') to only kill true orphans.

    One-line install: git clone https://github.com/anthropics/cc-reaper && cd cc-reaper && bash install.sh

    Not a fix for the root cause, but keeps RAM under control until the team addresses process lifecycle management properly. Hope this helps others hitting this issue.

  6. abix- commented on Mar 4, 2026

    @abix-

    statusline.sh orphans on Windows

    Statusline spawns bash.exe (Git Bash) per update. On Windows, they're never killed when the parent exits. 88 orphans in ~1h43m (~1/min). Same root cause -- no signal propagation through MSYS2.

    Inline jq command still spawns bash.exe, so no user-side fix. We've disabled statusline on Windows.

    Get-CimInstance Win32_Process -Filter "Name = 'bash.exe'" |
        Where-Object { $_.CommandLine -match 'statusline\.sh' } |
        ForEach-Object {
            try { Get-Process -Id $_.ParentProcessId -EA Stop | Out-Null }
            catch { [PSCustomObject]@{ PID = $_.ProcessId; ParentPID = $_.ParentProcessId } }
        }
    
  7. github-actions commented on Apr 1, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  8. github-actions commented on Apr 9, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  9. locked as resolved and limited conversation to collaborators on Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions