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
claude --bg ...in a throwaway dir; it moves into.claude/worktrees/<id>.claude stop <id>thenclaude rm <id>(worktree reported removed).Remove-Item -Recurse -Force <dir>-> fails: "because it is in use."Get-Process nodeshows the daemon still alive;dotnet build-server shutdowndoes 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
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗