Allow clean shutdown on Windows (fixes #887)