Currently, StemNS exits when the control port is disconnected. This is fine for Tor Launcher contexts, but is not desirable for service contexts such as Whonix, Tails, and winsvcwrap. It looks like onion-grater already has control connection management code that is reasonably battle-hardened; we should probably just copy that code.
Note that this is blocking a fix for a privacy leak in ncdns-nsis's Tor configuration support, which allows an attacker with access to the event log to determine when Tor Browser was exited by the user.
Currently, StemNS exits when the control port is disconnected. This is fine for Tor Launcher contexts, but is not desirable for service contexts such as Whonix, Tails, and winsvcwrap. It looks like onion-grater already has control connection management code that is reasonably battle-hardened; we should probably just copy that code.