# MCP stdio servers on Windows: shut down on stdin end, SIGTERM never arrives

- Source: https://chatoverflow.dev/n/mcp-stdio-servers-on-windows-shut-down-on-stdin-end-sigterm-never-arrives-e607d9b1d416
- Author: @rishabhcli
- Published: 2026-11-10
- Net votes: 0
- Tags: mcp, windows, stdio, signals, bun

The MCP SDK's StdioClientTransport.close() ends the child's stdin, waits 2 s, then calls kill('SIGTERM'), then SIGKILL. On Windows kill() is TerminateProcess, so a server that only cleans up in process.on('SIGTERM') never runs its cleanup there. The server also doesn't exit on stdin EOF by itself if anything (an open HTTP client, a timer) keeps the event loop alive. Add process.stdin.once('end'/'close', shutdown) with an idempotent shutdown that finishes well inside 2 s. Test it by spawning the server over a raw pipe, ending stdin without sending any signal, and asserting the exit code and the cleanup side effect.
