[BUG] Windows: cleanup `taskkill /PID x /T /F` spawned by Claude Code hangs forever and accumulates by the hundreds (process + memory leak)

Open 💬 1 comment Opened Jun 12, 2026 by Sentence

Summary

On Windows, the taskkill /PID <pid> /T /F commands Claude Code spawns for process cleanup hang indefinitely instead of exiting. Over a day of normal multi-session use they accumulate by the hundreds, each dragging a conhost.exe host, until the whole machine becomes sluggish.

Environment

  • Claude Code 2.1.175
  • Windows 11 Home 10.0.26200
  • PowerShell 7.6.2 (harness shell), Git Bash present
  • Terminal: Warp
  • Typical usage: 5–7 concurrent interactive sessions

Observed state

Snapshot from a machine that had been running normally (no reboot) — 960 processes total:

| Process | Count | Total working set |
|---|---|---|
| taskkill.exe (hung) | 384 | 4.8 GB |
| conhost.exe | 481 | 3.3 GB |
| node.exe (MCP servers, many orphaned) | 86 | 5.0 GB |
| bash.exe (shell-snapshot chains, orphaned) | 148 | 1.2 GB |
| claude.exe (live sessions) | 6 | 2.7 GB |

  • Every sampled hung taskkill had a live claude.exe process as its parent, command line taskkill /PID <pid> /T /F. These are not orphans from crashed sessions — running sessions spawn them and they never exit.
  • Some hung for hours (system had ~32 GB RAM, 2.2 GB in Memory Compression, Defender working overtime scanning the spawn churn).
  • Burst behavior: at one point 147 fresh taskkill processes appeared within ~1 minute, all children of the live sessions — looks like a retry loop when the previous kill never completes.
  • Side effect: WMI (winmgmt) repeatedly failed mid-query ("WBEM server is shutting down") under this load.

Additional detail

Force-killing the orphaned conhost.exe processes also released the hung taskkill clients (console client dies with its host), which suggests the hang involves the console session rather than the target PID. The PIDs being killed no longer existed at inspection time.

Repro

No deterministic repro — emerges over hours of normal use with several concurrent sessions on Windows (background Bash tasks, subagents, MCP servers configured: codegraph, context7). State above accumulated within roughly a day.

Expected

taskkill cleanup calls exit within seconds (success or failure), or are reaped by Claude Code after a timeout.

Workaround

Scheduled task every 15 min: kill taskkill.exe older than 10 minutes and conhost.exe/MCP node.exe/snapshot bash.exe whose parent PID is dead. This caps the leak but doesn't address the cause.

Possibly related

#66151 (Stop-hook bash orphans on Windows), #61617 (subagent grep outlives session), #62107 (scheduled tasks leave claude.exe alive), #61342 (taskkill orphan subprocesses blocking Desktop relaunch), #58606 (visible conhost flash on Windows tool calls).

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗