Processes become orphaned when terminal closes instead of exiting on macOS

Resolved 💬 3 comments Opened Jan 27, 2026 by ryanmish Closed Jan 31, 2026

Description

When closing a terminal with an active Claude Code session, the Claude process doesn't terminate. Instead it becomes orphaned and continues running in the background indefinitely.

Environment

  • Claude Code versions affected: 2.1.12, 2.1.14, 2.1.17, 2.1.20 (likely all versions)
  • OS: macOS 15.6.1 (Sequoia)
  • Hardware: Apple M1 Max
  • Shell: zsh

Symptoms

After closing terminals that had active Claude sessions, the processes remain running:

$ ps -p <orphaned_pid> -o ppid,stat,tty
PPID STAT TTY
   1 S    ??
  • PPID = 1: Process has been adopted by launchd (orphaned)
  • TTY = ??: No controlling terminal attached

Current State on My Machine

With only one terminal open running Claude, there are 7 Claude processes:

| PID | Version | Started | Accumulated CPU Time |
|-----|---------|---------|---------------------|
| 1341 | 2.1.17 | Friday 10AM | 220 minutes |
| 11539 | 2.1.17 | Friday 10AM | 126 minutes |
| 18265 | 2.1.12 | Jan 20 | 159 minutes |
| 27162 | 2.1.12 | Tuesday 2PM | 96 minutes |
| 58491 | 2.1.14 | Wednesday 11AM | 27 minutes |
| 65051 | 2.1.14 | Wednesday 12PM | 71 minutes |
| 32557 | 2.1.20 | Today | (active session) |

6 of these are orphaned from previous terminal sessions that were closed.

Reproduction

  1. Open a terminal
  2. Start claude
  3. Close the terminal window (not the Claude session, the terminal itself)
  4. Run pgrep -fl claude - the process is still running
  5. Run ps -p <pid> -o ppid,tty - shows PPID=1, TTY=??

Expected Behavior

When the controlling terminal is closed, Claude should detect this (via SIGHUP or by detecting the closed TTY) and exit gracefully.

Impact

  • Accumulates background processes over time
  • Each orphaned process continues using memory (~100-500MB each)
  • Can lead to confusion about which processes are actually active

View original on GitHub ↗

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