From a80c7a26dd8355d0ae476af3b9b3dc9e88fe1a17 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Mon, 27 Apr 2020 18:03:10 -0700
Subject: [PATCH] Wait for threads before SDL_Quit (lol)

---
 src/sdl/i_system.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c
index 9ef8e5a11..3237b5ec8 100644
--- a/src/sdl/i_system.c
+++ b/src/sdl/i_system.c
@@ -2254,7 +2254,7 @@ INT32 I_StartupSystem(void)
 	SDL_GetVersion(&SDLlinked);
 #ifdef HAVE_THREADS
 	I_start_threads();
-	atexit(I_stop_threads);
+	I_AddExitFunc(I_stop_threads);
 #endif
 	I_StartupConsole();
 #ifdef NEWSIGNALHANDLER