Fix a crash in OpenGL on game shutdown.
Cleanup shutdown on Windows to avoid races.

Was still getting crashes sometimes.
Refactor a bit, curly style.
Fix a possible race on shutdown.
Avoid Core_Stop() for reset, it might not reset.
This doesn't really "wait" anymore.
Merge pull request #4136 from unknownbrackets/ui-tweaks

Improve some shutdown problems on Windows