Orphaned processes after terminal close cause runaway memory consumption (34GB+ per instance)
Status Closed — not planned
Maintainer reply None cached
Workaround ✓ Mentioned in thread ↓
Activity 15 comments · opened Jan 10, 2026 · closed Feb 28, 2026
Description
When closing iTerm2 (and likely other terminals) without explicitly exiting Claude Code first, the node processes become orphaned instead of terminating. These orphaned processes then experience runaway memory consumption, each ballooning to ~34GB of V8 heap before crashing with OOM.
Environment
- OS: macOS 15.5 (24F74)
- Architecture: ARM64 (Mac16,13 - MacBook Air)
- Terminal: iTerm2
Reproduction
- Open multiple iTerm2 windows/tabs with Claude Code sessions running
- Close iTerm2 (Cmd+Q or close windows) without explicitly exiting Claude Code
- Observe orphaned node processes consuming increasing amounts of RAM
- Eventually each process crashes with V8 OOM at ~34GB
Evidence from Crash Reports
Crash 1 (orphaned)
"pid" : 52713
"parentProc" : "Exited process"
Memory Tag 255: 34.3G (16,444 regions)
Crash 2 (orphaned)
"pid" : 40417
"parentProc" : "Exited process"
Memory Tag 255: 34.3G (16,424 regions)
Stack trace shows V8 OOM:
node::OOMErrorHandler
→ v8::internal::V8::FatalProcessOutOfMemory
→ v8::internal::Heap::FatalProcessOutOfMemory
→ v8::internal::Heap::CollectGarbage
Impact
In one incident, 8+ Claude Code instances went to ~4GB each simultaneously before crashing, causing system-wide memory pressure and requiring a restart.
A separate incident spawned 10 rapid-fire subagent processes that all crashed with OOM within 30 seconds.
Expected Behavior
Claude Code should:
- Properly handle
SIGHUPsignal when terminal closes - Terminate gracefully instead of becoming an orphan
- Not experience runaway memory allocation if orphaned
Workaround
Explicitly exit Claude Code before closing terminal windows:
Ctrl+Cto interrupt- Or type
/exit
15 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Having same issue
I have orphaned processes in zellij inside of wezterm. https://github.com/anthropics/claude-code/issues/18752
🔗 Related: New trigger scenario
Found another way to trigger orphaned processes: context limit reached (without terminal close or
/exit).See #18981 — when the context percentage mismatch bug (#18241) causes premature "Context limit reached", background agents aren't cleaned up. Same symptom (orphaned process at 100%+ CPU), different trigger.
This suggests the cleanup mechanism may need to listen for multiple session-end signals, not just terminal/exit events.
Also encountering this. It started happening after a recent update.
<img width="1305" height="707" alt="Image" src="https://github.com/user-attachments/assets/5181278a-097b-469d-bc49-db40e595f53a" />
workaround for macos https://gist.github.com/yowmamasita/f3458e89367a82fbdee4366f456ed576
Also happening for me. When I close terminal tab, I expect claude code process to be killed
I came to report the same issue.
I think it's a new regression in the native build since I think I would have noticed it weeks ago otherwise.
It should exit on sighup.
@danneu it also happens with the npm build
Additional case report
Experiencing the same issue on macOS with iTerm2 and PyCharm integrated terminal.
Observed behavior
After closing terminals without explicitly exiting Claude Code, found 22+ orphan processes accumulated over several days:
Environment
preferredNotifChannel: "iterm2_with_bell"Workaround
I created a simple cleanup tool for macOS users:
👉 claude-code-cleanup - Double-click to run, shows running processes, and kills orphaned ones.
Or use terminal:
Prevention
Until this is fixed, exit Claude Code properly before closing terminal:
/exitCtrl+CthenCtrl+D+1 for implementing proper SIGHUP handling.
Update: This issue appears to be fixed in v2.1.19.
I was on v2.1.15 and upgraded via
brew upgrade claude. After the update, orphan processes no longer seem to persist when closing the terminal.Can others confirm?
yeah it's fixed in v2.1.19
Additional reproduction case: Subagents not terminated on Ctrl+C
Environment
Observation
Even when explicitly terminating Claude Code with
Ctrl+C, subagent processes (spawned via theTasktool) are not terminated and become orphaned.In my case, I found 154 orphaned Claude Code processes after several sessions were closed with
Ctrl+Cover the course of a day.Breakdown:
--output-format stream-jsonflags (subagents)System Impact
Root Cause
The issue appears to be that
SIGINT(Ctrl+C) is not propagated to child processes spawned by theTasktool. When the parent process terminates, these subagents become orphaned instead of being cleaned up.Suggested Fix
SIGINT/SIGTERM/SIGHUPto all child processessetpgid) so the entire process tree can be terminated togetherWorkaround
Manual cleanup of orphaned processes:
Or periodic monitoring:
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
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.