Fix native macOS quit and Dock reopen lifecycle (#4222)