about summary refs log tree commit diff stats
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c
index 47cff957..a66e743b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1234,13 +1234,13 @@ void endBox64()
     if(!my_context || box64_quit)
         return;
 
+    // then call all the fini
+    box64_quit = 1;
     endMallocHook();
     x64emu_t* emu = thread_get_emu();
     // atexit first
     printf_log(LOG_DEBUG, "Calling atexit registered functions (exiting box64)\n");
     CallAllCleanup(emu);
-    // then call all the fini
-    box64_quit = 1;
     printf_log(LOG_DEBUG, "Calling fini for all loaded elfs and unload native libs\n");
     RunElfFini(my_context->elfs[0], emu);
     FreeLibrarian(&my_context->local_maplib, emu);    // unload all libs
@@ -1861,7 +1861,7 @@ int main(int argc, const char **argv, char **env) {
     // Get EAX
     int ret = GetEAX(emu);
     printf_log(LOG_DEBUG, "Emulation finished, EAX=%d\n", ret);
-
+    endBox64();
 #ifdef HAVE_TRACE
     if(trace_func)  {
         box_free(trace_func);