Description
When a head calls stream/stop, hydraheadflatscreen kills Moonlight with SIGKILL (exit -1). Sunshine's undo prep-cmd hook only fires on a clean client quit, not on abrupt kills — so the hook never fires during normal stream stops from the head.
Result: hydrabody's in-memory session registry stays Active, the experience process keeps running, and the body reports stream_status=streaming. Only the stale session watchdog (port 47998 ESTABLISHED check, 2-min timeout) eventually cleans it up — a 2-3 minute window on every stream stop, not just crashes.
Root cause: the undo hook fires when Moonlight sends a proper quit packet to Sunshine before disconnecting. Killing Moonlight with SIGKILL/TerminateProcess skips that packet.
Fix (hydraheadflatscreen): after stream/stop, call POST /api/v1/stream/stop on the body. This endpoint (v2.0.45+) calls Sunshine's CloseRunningApp API and clears the in-memory session registry immediately.
Workaround: hydrabody v2.0.45+ has the watchdog + the manual endpoint. Recovery is automatic but slow.