Skip to content

[BUG] orphaned processes from subagents crashing computer #18405

@JasenNelson

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

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