OSX: window close event and glwtQuit fix

Handle windowShouldClose instead of windowWillClose event to get
behavior that is more like other platforms.

Don't terminate the app on glwtQuit.

NSApplocation terminate terminates the entire process, not only the runloop
of the NSApplication object. Using stop instead of terminate only stops the
runloop so we use that instead.

Clean up and refactor window init and cleanup.
OSX: Fix glwtEventHandle(wait=0)

Make glwtEventHandle behave nicely when nextEventMatchingMask returns
nil.

Remove application.[mh] and move keyboard event workaround to
glwtEventHandle instead of subclassing NSApplication.