Windows: background daemon keeps a directory handle after `claude rm`, blocking directory deletion

Resolved 💬 1 comment Opened May 31, 2026 by HakanCOSKUN Closed Jul 3, 2026
Discovered while piloting single-terminal background dispatch (claude agents / claude --bg) for real development work on Claude Code 2.1.157.

What's wrong

After stopping and removing a background session, the per-user background daemon (node process) does not promptly release the handle to the session's working directory, so deleting that directory fails with "in use" on Windows.

Steps to reproduce

  1. claude --bg ... in a throwaway dir; it moves into .claude/worktrees/<id>.
  2. claude stop <id> then claude rm <id> (worktree reported removed).
  3. Remove-Item -Recurse -Force <dir> -> fails: "because it is in use."
  4. Get-Process node shows the daemon still alive; dotnet build-server shutdown does not help. Deleting files individually succeeds, but the directory handle persists.

Expected

After claude rm, the daemon releases all handles to the removed session's directory so it can be deleted.

Actual

Directory handle persists until the daemon process exits.

Environment

  • Claude Code 2.1.157
  • Windows 11

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗