[BUG] Silent graceful exit during Write/Bash operations on Windows (NPM installation)

Resolved 💬 18 comments Opened Feb 3, 2026 by renatoacairo Closed Apr 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code exits silently (returns to PowerShell prompt) during coding tasks. No error message, no stack trace, no crash dump generated. The process exits gracefully (process.exit()) rather than crashing.

Key characteristic: Crashes happen during coding tasks (Edit, Write, Bash) but NOT during research tasks (WebFetch, Read, browsing docs) — even when research loads heavy context.

What Should Happen?

Claude Code should continue running or display an error message if something goes wrong.

Environment

| Component | Value |
|-----------|-------|
| Claude Code Version | 2.1.29 |
| Installation Method | NPM (npm install -g @anthropic-ai/claude-code) |
| Platform | Windows 11 |
| Terminal | Windows Terminal / PowerShell |

Evidence Collected

1. Crash Dump Analysis

Crash dump collection was configured via Windows Error Reporting:

HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\node.exe
    DumpFolder = %TEMP%\CrashDumps
    DumpType = 2 (full dump)

Result: No dump files generated despite multiple crashes. This proves the process exits gracefully (calls process.exit()) rather than crashing with an exception.

2. Windows Event Log

No node.exe crashes logged in Windows Application Event Log over 7 days of crashes.

3. Debug Output

Ran with DEBUG=* and NODE_OPTIONS=--unhandled-rejections=warn:

  • Heavy traffic to api.anthropic.com/api/event_logging/batch (telemetry)
  • Traffic to http-intake.logs.us5.datadoghq.com/api/v2/logs (Datadog)
  • Garbled output (task list text mixed with debug output) suggesting concurrent stdout writes
  • No error message before exit
  • No unhandled rejection warning despite flag being set
4. PowerShell Transcript Capture

Used Start-Transcript to capture session output:

● Write(tools\evals\baselines.py)
  ⎿  Wrote 1 lines to tools\evals\baselines.py
...
PS>TerminatingError(): "O pipeline foi interrompido."
>> TerminatingError(): "O pipeline foi interrompido."
>> TerminatingError(): "O pipeline foi interrompido."

Observations:

  • Crash occurred during/after Write operation
  • Error "The pipeline was interrupted" repeated 3 times
  • Multiple concurrent operations terminated simultaneously
  • Consistent with process.exit() killing all pending async operations
5. Exit Code and Process Monitor Analysis

Exit code: 0 (success)

Process Monitor capture (node.exe Process Exit events):

10:22:21  node.exe  53344  Exit Status: 0  Private: 325 MB  (main process, 12 sec runtime)
+ 6 subprocess exits, all with Exit Status: 0

Critical finding: Exit code 0 confirms Claude Code is deliberately exiting, not crashing. Something in the code calls process.exit(0) during Write operations without displaying an error.

6. Debug Log Analysis

Claude Code writes debug logs to ~/.claude/debug/. Captured the session log before exit:

Last entries before crash:

13:22:20.663Z [DEBUG] File tools\evals\baselines.py written atomically
13:22:20.669Z [DEBUG] PostToolUse hook for Write completed
13:22:21.135Z [DEBUG] LSP Diagnostics: Checking registry - 0 pending
13:22:21.150Z [DEBUG] [API:request] Creating client...
13:22:21.152Z [DEBUG] [API:auth] OAuth token check complete
13:22:21.183Z [DEBUG] [lspRecommendation] Looking for LSP plugins for .py
<-- Process exits here with status 0, no error logged -->

Key observation: The debug log shows normal operation right up until exit. No error, no warning, no exception — just stops mid-operation after a successful Write and while preparing the next API request.

Process Monitor confirms the shutdown sequence started immediately after (saving .claude.json, cleaning up lock files, thread exits) — all with SUCCESS status.

7. Ruled Out Causes

| Suspect | How Ruled Out |
|---------|---------------|
| Windows Defender | Added exclusions for Projects folder, .claude, npm, node.exe — still crashes |
| File locking (Sublime Text) | Closed entirely — still crashes |
| Cloud sync (OneDrive/Dropbox) | Verified not running, folder not synced — still crashes |
| Unhandled promise rejection | --unhandled-rejections=warn set, no warning shown |
| Bun panic (#18567) | That shows error message; this is silent. Also using NPM install, not native |
| Telemetry/event logging | Set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 — still crashes |
| Parallel agent execution | Ran tasks sequentially (no parallel processes) — still crashes |
| Notification hooks | Removed all hooks from settings.json — still crashes |
| Statusline | Removed statusline config — still crashes |

Steps to Reproduce

  1. Install Claude Code via NPM on Windows 11
  2. Run intensive coding tasks (executing a plan with multiple Write/Edit/Bash operations)
  3. Eventually (unpredictably) Claude Code exits silently back to PowerShell prompt
  4. No error message shown
  5. Check %TEMP%\CrashDumps — no dump files (confirming graceful exit)

Pattern Observed

  • Happens during Write operations (file creation/editing)
  • Happens during Bash operations (git commands, pytest, etc.)
  • Does NOT happen during research (Read, WebFetch, WebSearch)
  • Context usage is low (~20-30%) when it happens — not context overflow
  • Fresh terminal tabs affected — not accumulated state
  • Affects all projects — not project-specific configuration

Hypothesis

Based on evidence, something in Claude Code's Write/Bash handling or telemetry code path calls process.exit() under certain conditions without logging an error. The heavy telemetry traffic visible in debug output suggests the issue may be related to event logging.

Diagnostic Files

If helpful, I can provide:

  • Full debug output from crashed session
  • Windows Event Log export
  • Process Monitor capture of the exit

Additional Information

  • Minimal config: No hooks, no statusline, telemetry disabled — still crashes
  • Machine has 16GB+ RAM, not under memory pressure
  • This is NOT the Bun panic issue (#18567) — that shows an error, this is silent
  • Crashes happen even with sequential task execution (no parallel agents)
  • Context usage is low (~20-30%) when crashes occur — not context overflow

Conclusion

All user-configurable factors have been ruled out through systematic testing. Multiple diagnostic methods confirm this is NOT a crash:

  1. Exit code 0 — Process exits "successfully"
  2. No crash dump — Despite dump collection being configured
  3. Process Monitor — All file operations succeed, clean shutdown sequence
  4. Debug log — No error logged, normal operation until sudden exit

Claude Code is deliberately calling process.exit(0) after Write operations without displaying an error. The debug log shows it stops mid-operation (after Write, while preparing next API request) with no warning.

This appears to be a bug in Claude Code's internal control flow — possibly in the API request handling, LSP integration, or async operation management — that triggers a clean exit when it shouldn't.

View original on GitHub ↗

18 Comments

renatoacairo · 5 months ago

Additional info:

Node.js version: v22.19.0

Related Windows silent exit issues:

  • #21831 — Silent exit when clearing .next cache (file system error trigger)
  • #22226 — Silent crash on large paste input (input size trigger)

All three issues share the same symptom (silent exit, no error message, exit code 0) but different triggers. This suggests a common underlying issue in Windows error handling or async operation management.

renatoacairo · 5 months ago

Debug log from crashed session attached:

https://gist.github.com/renatoacairo/040469e1978acf655edef14b1d9386d9

Key observation (lines 387-409):

  • Write operation completes successfully (line 395: "File written atomically")
  • PostToolUse hooks complete (line 400)
  • LSP Diagnostics check (line 402)
  • New API request preparation begins (lines 403-407)
  • Last entry (line 408): [lspRecommendation] Looking for LSP plugins for .py
  • Process exits with status 0 — no error logged

The log shows normal operation right up until the sudden exit. Something in the LSP recommendation lookup or subsequent API request handling triggers process.exit(0) without logging an error.

github-actions[bot] · 5 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/20782
  2. https://github.com/anthropics/claude-code/issues/21831
  3. https://github.com/anthropics/claude-code/issues/20759

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

renatoacairo · 5 months ago

This is NOT a duplicate of #20782, #21831, or #20759.

Those issues all have identifiable errors in their logs:

  • #20782: Tool mcp__plugin_playwright_playwright__browser_install not found (MCP error)
  • #21831: SyntaxError: Unexpected token in .jsonl files (corrupted session files)
  • #20759: Same JSON parsing errors as #21831

All three are from the same author, same project, with the same corrupted session files causing parse errors.

This issue is fundamentally different:

| Evidence | Other issues | This issue |
|----------|-------------|------------|
| Error logs | Have stack traces | None |
| Debug log | Shows errors | Shows normal operation → sudden exit |
| Root cause | Visible (corrupted files, MCP) | Unknown - no error logged |
| Diagnostic depth | Feedback submission | Process Monitor, crash dump analysis, debug logs |

The entire point of this bug report is that there is no error. The process calls process.exit(0) during normal operation without logging anything. This is proven by:

  1. Exit code 0 (not a crash)
  2. No crash dump generated despite dump collection being configured
  3. Debug log showing clean operation until mid-API-request sudden stop
  4. Process Monitor confirming graceful shutdown sequence

Closing this as a duplicate of issues that have identifiable errors would lose the investigation into why Claude Code silently exits without any error during normal Write operations.

renatoacairo · 5 months ago

New evidence: Multi-tab crash pattern (2026-02-03)

Just experienced a crash affecting 2 out of 4 open tabs simultaneously, with the other 2 surviving. This provides new diagnostic data.

Crash details

| Tab | Project | State at crash | Outcome |
|-----|---------|----------------|---------|
| 1 | igum | Mid-Update (editing tools\evals\checks.py) | CRASHED |
| 2 | claude-code-backup | Permission prompt (waiting for user input on git commit) | CRASHED |
| 3 | breshowzinho-automator | Idle | Survived |
| 4 | igum | Idle | Survived |

What this rules out

  • Not project-specific — Two different projects crashed
  • Not MCP-related — Same project (igum) had one tab crash and one survive
  • Not Windows Terminal crash — That would kill all 4 tabs (parent process)

Pattern identified

Active/transitioning tabs crash. Long-idle tabs survive.

The crashed tabs were either:

  1. Actively processing a tool result (mid-Update)
  2. In a permission prompt state (post-response, waiting for input)

The surviving tabs had been idle for some time with no active API connection or internal state processing.

Additional crash (same day)

A separate tab crashed right after Claude finished responding — the response was fully rendered, waiting for my input. Last visible output:

● Good catches. Let me address both:
  [... detailed response about CI path filters and Haiku vs Sonnet ...]
  Want me to update the workflow with the path filters?

This is consistent with the debug log findings: crashes occur in the post-tool-completion transition (after PostToolUse hook completed, while LSP/API initialization runs).

Refined hypothesis

The exit isn't triggered by Write/Bash operations themselves, but by the transition state after tool completion — specifically during LSP diagnostics, API client creation, or OAuth token checks (as shown in the debug log). Tabs that are fully idle have exited this vulnerable state; tabs actively processing or just-finished remain in it.

renatoacairo · 5 months ago

Update: WSL/Ubuntu stability finding

After switching from native Windows (PowerShell) to WSL/Ubuntu, no crashes have occurred even during heavy coding sessions with multiple Write/Edit/Bash operations.

Environment comparison

| Factor | Native Windows (crashes) | WSL/Ubuntu (stable) |
|--------|--------------------------|---------------------|
| Shell | PowerShell | Bash |
| File system | NTFS | ext4 (through WSL2) |
| Node.js build | Windows | Linux |
| Terminal | Windows Terminal (native tab) | Windows Terminal (WSL tab) |

Implications

This strongly suggests the issue is Windows-specific, likely related to:

  1. Windows file I/O handling (NTFS vs ext4)
  2. Node.js Windows build behavior (signal/process handling)
  3. PowerShell vs Bash interactions with the Claude Code process
  4. Windows-specific code paths in Claude Code

Workaround

For Windows users experiencing this: Running Claude Code in WSL instead of native Windows appears to avoid the crashes entirely.

This doesn't fix the underlying bug but may help other users until it's addressed.

Nantris · 4 months ago

This is possible the same issue I reported today in #30959 which I closed in favor of this.

Seanbo5386 · 4 months ago

Any luck with this? I believe my issue #32386 could be the same issue you are experiencing.

Nantris · 4 months ago

This happens like ten times a day - sometimes immediately after you send a message and other times twenty minutes into an agent's work. This is really undermining the promise of agentic workflows.

syg-alexsander · 4 months ago

I've noticed on my case, after agents started crafting data from my Spec-Driven Dev, my RAM usage went up to 96% and terminal froze. A few seconds later, Claude exited to powershell.

Nantris · 3 months ago

In my case the exit does not seem related to RAM usage from what I can tell but my eyes aren't glued to Task Manager so it's possible that there's a sudden and large spike and Claude Code exits. But this issue seems entirely to revolve around unexpected graceful exits.

When memory is under strain I've seen Bun crashes or other non-graceful exits but this seems different and I've even seen it within a moment of submitting my message which seems unlikely Claude would have had time to spike the memory without some serious flaw.

Nantris · 3 months ago

Seems like a different but fun Claude Code exit that occurs due to something specific to the directory:

~~I can no longer use Claude Code on my Windows machine as a result of my issue, which may be distinct from the original issue based on what I'm seeing now. The version has not changed (2.1.69) however it consistently exits within 15 seconds. This sort of issue on Windows really needs attention. It is now a show-stopper for me.~~

~~I tried updating Claude Code to 2.1.79 and I tried Cygwin and Cmd but both exit the same way. Deleted .claude/settings.json but the problem persists.~~

~~claude doctor shows nothing obviously wrong.~~

Edit: My issue here was #36400. I still see this issue (22735) in addition though.

MichaelCharles · 3 months ago

My issue was closed in favor of this one, despite the fact that for me it is happening with the native install, not the NPM installation.

Also I have additional information, when kicked out of Claude Code and back into the terminal, [O[I[O[I[O[ is output into the command line as though it is user input.

![](https://i.imgur.com/bKdRRZ8.png)

Nantris · 3 months ago

@MichaelCharles mine is also native install. Never seen the character string but I'm not in PowerShell.

MichaelCharles · 3 months ago

Another symptom at least in my case is that if I /resume a chat that previously failed, upon resume it immediately exits and kicks me back to the command prompt.

So I had Claude Code work on this issue in my environment and it came up with a workaround that is, so far, working for me. I had it summarize it's findings which I've edited and copy/pasted below.

---

Root Cause Analysis & Workaround

Finding

Claude Code registers multiple process.on("SIGINT") handlers. The first one registered (in the main entry function, VLY in minified code) calls process.exit(0) directly with no logging:

// Handler 1 — registered first, in main entry point
process.on("SIGINT", () => {
  if (process.argv.includes("-p") || process.argv.includes("--print")) return;
  process.exit(0);  // immediate exit, no logging
});

A second handler registered later during initialization does the right thing — logs a shutdown signal and performs graceful cleanup:

// Handler 2 — registered later, during init
process.on("SIGINT", () => {
  o8("info", "shutdown_signal", { signal: "SIGINT" });
  kq(0);  // graceful shutdown
});

Since Node.js calls listeners in registration order and process.exit() is synchronous, Handler 1 kills the process before Handler 2 ever runs. This explains:

  • Exit code 0 — explicit process.exit(0)
  • No error or shutdown log — Handler 1 has no logging
  • No crash dump — it's a clean exit

Debug logs from crashed sessions confirm this: they end abruptly with no shutdown_signal entry, which would be present if Handler 2 had run.

Something on Windows is delivering SIGINT to the process during normal operation. I didn't determine exactly what, but it's happening during concurrent I/O (post-tool-use hooks, LSP diagnostics, API requests). It's also worth noting that there's an orphan detection mechanism (checking stdout.writable/stdin.readable) that is explicitly skipped on Windows via a process.platform !== "win32" guard.

Resume behavior

This also explains why /resume-ing a crashed session immediately crashes again — resuming replays the conversation through the same code paths and I/O patterns, recreating the conditions that trigger the spurious SIGINT.

Workaround

I patched the npm-installed cli.js to make Handler 1 a no-op, deferring to Handler 2 for graceful shutdown:

mkdir -p ~/.claude-patched && cd ~/.claude-patched
npm init -y && npm install @anthropic-ai/claude-code

sed -i 's/process\.on("SIGINT",()=>{if(process\.argv\.includes("-p")||process\.argv\.includes("--print"))return;process\.exit(0)})/process.on("SIGINT",()=>{if(process.argv.includes("-p")||process.argv.includes("--print"))return;\/\*patched:noop,defer to graceful handler\*\/})/' \
  node_modules/@anthropic-ai/claude-code/cli.js

# Run with:
node node_modules/@anthropic-ai/claude-code/cli.js

Suggested fix

The SIGINT handler in the main entry function (VLY) should either be removed entirely or changed to use the graceful shutdown path (kq(0)) instead of process.exit(0). The handler registered during initialization already handles SIGINT properly.

MichaelCharles · 3 months ago

I've been using Claude Code heavily since creating the patched version I described in the comment above, and I'm no longer having this issue. This does seem to be something that can be resolved by updating cli.js.

github-actions[bot] · 2 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] · 2 months ago

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.