mac: Fix a crash when closing window