diff --git a/platform/macos/godot_application_delegate.mm b/platform/macos/godot_application_delegate.mm index a3ee8c73c31..0421ea92e99 100644 --- a/platform/macos/godot_application_delegate.mm +++ b/platform/macos/godot_application_delegate.mm @@ -240,7 +240,7 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { DisplayServerMacOS *ds = (DisplayServerMacOS *)DisplayServer::get_singleton(); - if (ds) { + if (ds && ds->has_window(DisplayServerMacOS::MAIN_WINDOW_ID)) { ds->send_window_event(ds->get_window(DisplayServerMacOS::MAIN_WINDOW_ID), DisplayServerMacOS::WINDOW_EVENT_CLOSE_REQUEST); } OS_MacOS *os = (OS_MacOS *)OS::get_singleton(); diff --git a/platform/macos/os_macos.mm b/platform/macos/os_macos.mm index 47397614846..439f43da319 100644 --- a/platform/macos/os_macos.mm +++ b/platform/macos/os_macos.mm @@ -882,9 +882,9 @@ void OS_MacOS::terminate() { void OS_MacOS::cleanup() { if (main_loop) { main_loop->finalize(); - @autoreleasepool { - Main::cleanup(); - } + } + @autoreleasepool { + Main::cleanup(); } }