WPF: Fixed bug where the app would not close correctly when multiple windows were opened.

- Also should have fixed build on iOS, OSX, Linux and Android.