Orphan processes remain after closing terminal (iTerm/PyCharm)

Resolved 💬 3 comments Opened Jan 24, 2026 by Joowonoil Closed Jan 29, 2026

Description

When closing the terminal application (iTerm2, PyCharm terminal) without explicitly exiting Claude Code, the Claude processes become orphaned and continue running in the background, consuming significant memory.

Steps to Reproduce

  1. Open Claude Code in iTerm2 or PyCharm terminal
  2. Use Claude Code normally
  3. Close the terminal window or quit the application directly (without running /exit or Ctrl+C)
  4. Check Activity Monitor or run ps aux | grep claude

Expected Behavior

Claude Code processes should terminate when the parent terminal is closed.

Actual Behavior

Claude processes continue running as orphan processes. Over time (days), dozens of processes accumulate, consuming significant memory (observed 3.4GB+ for a single process, with 20+ orphan processes total).

Example from ps aux:

username  63707 100.2 10.1 515016720 3397904   ??  R    금07오전  43:07.66 claude
username  63462  10.2  0.6 509344192 204832   ??  S    금07오전  69:49.41 claude
username  73132   7.8  0.6 510144016 196144   ??  S    금09오전  59:50.86 claude
... (20+ more processes from previous days)

Environment

  • OS: macOS (Darwin 25.2.0)
  • Terminal: iTerm2, PyCharm integrated terminal
  • Claude Code version: Latest (as of 2025-01-24)
  • Notification settings: preferredNotifChannel: "iterm2_with_bell"

Workaround

Users can manually kill orphan processes:

pkill -9 claude

Or exit properly before closing terminal:

  • Use /exit command in Claude Code
  • Use Ctrl+C then Ctrl+D

Suggestion

Claude Code should handle SIGHUP signal properly or set up a mechanism to detect when the parent terminal is gone and self-terminate.

View original on GitHub ↗

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