Fixes to correctly close MD when not in focus

Cherry-picked these commits:

[Mac] MacPlatform doesn't need static ctor (related)
https://github.com/mono/monodevelop/commit/2f1f7878619ea9702067b13e56288ac317c792ae

Xamarin Studio cannot be closed from the dock when it doesn't have focus
https://github.com/mono/monodevelop/commit/2a8311d413f18431958fe790eed8dfd7181fd64e

Added PlatformService.IsModalDialogRunning() 
https://github.com/mono/monodevelop/commit/4c55b9cb9f5250ccb2d4c72f7544fdc39b4394b9