Windows: /exit does not terminate child bash.exe processes — orphaned shells cause system-wide slowdown

Resolved 💬 5 comments Opened Mar 8, 2026 by FoodGoods Closed Apr 25, 2026

Bug Description

On Windows, when a Claude Code session that has executed tool calls is exited via /exit, the child bash.exe processes spawned during the session are not terminated. These orphaned shells continue spawning and dying at a rate of 5-8 processes every 2-3 seconds indefinitely, even though no task is running and Claude has printed "See ya!" and returned the shell prompt.

The only way to stop the orphaned shell churn is to force-close the terminal window. The shells do not self-terminate.

This causes real-world system degradation on Windows because endpoint protection software (F-Secure, Malwarebytes, Windows Defender) intercepts each bash.exe spawn, which backs up the disk I/O queue and makes the entire OS sluggish — not just Claude, but Explorer, right-click menus, Task Manager, everything.

Reproduction Steps

  1. Open a terminal on Windows and launch claude
  2. Give it any task that triggers tool use (e.g., "investigate why process X is running")
  3. Let it run for ~30 seconds so it spawns bash shells
  4. Press Esc to interrupt the task
  5. Type /exit — Claude prints "See ya!" and the shell prompt returns
  6. Leave the terminal window open — do NOT close it
  7. Monitor bash.exe processes via Task Manager or Get-Process bash
  8. Observe: 4-8 bash.exe processes continue spawning/dying every 2-3 seconds indefinitely

Expected: /exit should terminate all child processes. Bash shell count should drop to 0.

Actual: Orphaned bash shells continue churning at 5-8 per cycle. Only closing the terminal window kills them.

Evidence

We built a custom PowerShell monitoring script that logs Claude Code processes, bash shell counts, CPU%, RAM%, disk queue length, and antivirus memory every 2-3 seconds to CSV. Here is the annotated timeline from a single reproduction:

| Time | Event | Claude Processes | Bash Shells | Notes |
|------|-------|-----------------|-------------|-------|
| 10:33:01 | Baseline — idle, no task | 2 | 0 | System quiet |
| 10:33:44 | Task started | 2 | 1→3 | Shells begin spawning |
| 10:33:56 | Shell churn ramps up | 2 | 4-8 | BURST every 2-3s snapshot |
| ~10:34:39 | /exit executed — "See ya!" | 2→1 | 6-7 | Claude process exited, shells did NOT stop |
| 10:34:42–10:38:38 | 4 min of orphaned shells | 1 | 5-8 | Constant BURST, no task running |
| 10:37:19 | Disk queue spike | 1 | 6 | Disk queue = 4, CPU 13.6% |
| ~10:38:40 | Terminal window force-closed | 1 | 0 | Shells finally die |
| 10:38:44+ | System calm | 1 | 0 | CPU drops to 0.7-2.8% |

Additional observations:

  • Esc (interrupt) also does not stop the shell spawning
  • A Claude Code session that never ran a task (just sitting at the prompt in conversation mode) does not exhibit this behavior — it's specifically sessions that executed tool calls
  • F-Secure endpoint protection memory grew from 416 MB → 424 MB in 5 minutes purely from scanning the orphaned shell spawns
  • Each shell cycle creates 5-8 bash.exe processes consuming 40-65 MB total, which are then scanned by AV on every spawn

Impact

On systems with endpoint protection (which is most enterprise and many consumer Windows machines), this bug makes the entire OS unusable while the orphaned shells churn. The disk queue backs up from AV scanning each process spawn, which stalls all disk I/O system-wide. Users experience:

  • Multi-second delays on right-click context menus
  • Task Manager taking 5-10 seconds to open
  • Explorer freezing when navigating folders
  • General system-wide sluggishness

The workaround (closing the terminal window) is not obvious and users may leave terminal windows open, accumulating orphaned shell processes across multiple sessions.

Environment

  • OS: Windows 11 Pro 10.0.26200
  • Claude Code version: v2.1.71
  • Shell: PowerShell 7 (pwsh)
  • Terminal: Windows Terminal
  • AV: F-Secure Endpoint Protection (also confirmed with Malwarebytes)
  • Hardware: AMD Ryzen desktop, 64 GB RAM, Samsung NVMe drives

Related Issues

These existing issues describe adjacent but different problems:

  • #5545 — different scenario
  • #8865 — different scenario
  • #18405 — different scenario
  • #15423 — different scenario

None of them describe the specific behavior of /exit failing to terminate child bash.exe processes, or the continuous idle shell spawning pattern.

View original on GitHub ↗

This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗