diff --git a/ios/ViewController.mm b/ios/ViewController.mm index bdcf92e7d53d..ad334f0d8d41 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -213,7 +213,6 @@ - (void)viewDidLoad { time_update(); } - threadStopped = true; ILOG("Emulation thread shutting down\n"); NativeShutdownGraphics(); @@ -221,6 +220,8 @@ - (void)viewDidLoad { // Also ask the main thread to stop, so it doesn't hang waiting for a new frame. ILOG("Emulation thread stopping\n"); graphicsContext->StopThread(); + + threadStopped = true; }); } diff --git a/ios/main.mm b/ios/main.mm index ce1803e023da..e52f3f8bf9f5 100644 --- a/ios/main.mm +++ b/ios/main.mm @@ -61,7 +61,10 @@ bool System_GetPropertyBool(SystemProperty prop) { void System_SendMessage(const char *command, const char *parameter) { if (!strcmp(command, "finish")) { - exit(0); + dispatch_async(dispatch_get_main_queue(), ^{ + [sharedViewController shutdown]; + exit(0); + }); } }