Claude CLI processes not terminating when terminal closes
Status Closed — duplicate
Reported on v2.1.17
Maintainer reply None cached
Workaround ✓ Mentioned in description ↑
Activity 3 comments · opened Jan 24, 2026 · closed Jan 29, 2026
Description
Claude CLI processes continue running after the user closes or disconnects from the terminal, leading to significant memory accumulation over time.
Observed Behavior
- User closes terminal tab, Ctrl+C, or terminal disconnects
- Claude process continues running in background as orphan
- Process holds onto memory (600MB-3GB per session)
- Over days/weeks, multiple orphaned sessions accumulate
Evidence
On a system running for ~2 weeks, found 11 orphaned Claude sessions consuming ~10GB RAM:
PID: 1729372 | TTY: pts/27 | Started: Jan19 | Mem: 0.7%
PID: 1895002 | TTY: ? | Started: Jan20 | Mem: 0.4%
PID: 3047777 | TTY: ? | Started: Jan21 | Mem: 0.5%
PID: 3502757 | TTY: pts/12 | Started: Jan22 | Mem: 3.0%
PID: 3543434 | TTY: pts/13 | Started: Jan22 | Mem: 2.3%
PID: 3601287 | TTY: pts/21 | Started: Jan22 | Mem: 2.1%
PID: 3787540 | TTY: ? | Started: Jan23 | Mem: 1.6%
PID: 3955594 | TTY: pts/49 | Started: Jan22 | Mem: 1.4%
PID: 3959187 | TTY: pts/50 | Started: Jan22 | Mem: 2.4%
PID: 3960252 | TTY: pts/51 | Started: Jan22 | Mem: 0.9%
PID: 3963043 | TTY: ? | Started: Jan22 | Mem: 0.9%
Processes with TTY: ? had already lost their controlling terminal but were still running.
Expected Behavior
When the controlling terminal is closed or sends SIGHUP, the Claude process should:
- Detect the terminal disconnection
- Clean up resources
- Terminate gracefully
Environment
- OS: Linux 6.14.0-37-generic
- Claude CLI version: 2.1.17
Workaround
Users can manually clean up with:
pkill -f "claude"
Or check for orphaned processes:
pgrep -a claude
Suggested Fix
Implement proper signal handling for:
- SIGHUP (terminal hangup)
- SIGPIPE (broken pipe)
- Monitor stdin/tty availability and exit if lost
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗