diff --git a/src/m_menu.c b/src/m_menu.c
index f8240d40318322b1116a89c59310eaae827c25d4..0303b0de0078288f905a05a2d191cab425ae08ac 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -44,6 +44,7 @@
 #include "p_local.h"
 #include "p_setup.h"
 #include "f_finale.h"
+#include "lua_hook.h"
 
 #ifdef HWRENDER
 #include "hardware/hw_main.h"
@@ -6864,6 +6865,8 @@ static void M_SelectableClearMenus(INT32 choice)
 static void M_UltimateCheat(INT32 choice)
 {
 	(void)choice;
+	if (Playing())
+		LUAh_GameQuit();
 	I_Quit();
 }
 
@@ -12535,6 +12538,8 @@ void M_QuitResponse(INT32 ch)
 			I_Sleep();
 		}
 	}
+	if (Playing())
+		LUAh_GameQuit();
 	I_Quit();
 }