Skip to content

Orphan processes remain after closing terminal (iTerm/PyCharm) #20586

Closed as duplicate

Description

@Joowonoil

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.

Activity

  1. github-actions commented on Jan 24, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. Orphaned processes after terminal close cause runaway memory consumption (34GB+ per instance) #17391
    2. Orphaned Claude processes when parent terminal is killed #20117
    3. [BUG] Orphaned Claude Code processes accumulate - 5 processes using 1.4GB when only 1 session expected #19973

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. added
    duplicateThis issue or pull request already exists
    and removed
    bugSomething isn't working
    has reproHas detailed reproduction steps
    platform:macosIssue specifically occurs on macOS
    on Jan 29, 2026
  3. github-actions commented on Jan 29, 2026

    @github-actions

    This issue has been automatically closed as a duplicate of #17391.

    If this is incorrect, please re-open this issue or create a new one.

    🤖 Generated with Claude Code

  4. github-actions commented on Feb 6, 2026

    @github-actions

    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.

  5. locked as resolved and limited conversation to collaborators on Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions