Index: code/graphics/2d.cpp
===================================================================
--- code/graphics/2d.cpp	(revision 7218)
+++ code/graphics/2d.cpp	(working copy)
@@ -31,6 +31,7 @@
 #include "graphics/grbatch.h"
 #include "parse/scripting.h"
 #include "gamesequence/gamesequence.h"	//WMC - for scripting hooks in gr_flip()
+#include "Io/keycontrol.h" // m!m
 
 
 #if defined(SCP_UNIX) && !defined(__APPLE__)
@@ -1469,12 +1470,16 @@
 
 void gr_flip()
 {
-	//WMC - Evaluate global hook if not override.
-	Script_system.RunBytecode(Script_globalhook);
-	//WMC - Do conditional hooks. Yippee!
-	Script_system.RunCondition(CHA_ONFRAME);
-	//WMC - Do scripting reset stuff
-	Script_system.EndFrame();
+	// m!m avoid running CHA_ONFRAME when the "Quit mission" popup is shown. See mantis 2446 for reference
+	if (!quit_mission_popup_shown)
+	{
+		//WMC - Evaluate global hook if not override.
+		Script_system.RunBytecode(Script_globalhook);
+		//WMC - Do conditional hooks. Yippee!
+		Script_system.RunCondition(CHA_ONFRAME);
+		//WMC - Do scripting reset stuff
+		Script_system.EndFrame();
+	}
 
 	gr_screen.gf_flip();
 }
Index: code/io/keycontrol.cpp
===================================================================
--- code/io/keycontrol.cpp	(revision 7218)
+++ code/io/keycontrol.cpp	(working copy)
@@ -88,6 +88,7 @@
 									  // 666)6=N79+Z45=BE0e
 int Tool_enabled = 0;
 bool Perspective_locked=false;
+bool quit_mission_popup_shown = false;
 
 	/*
 #else 
@@ -1404,6 +1405,8 @@
 		game_stop_looped_sounds();
 		snd_stop_all();
 
+		quit_mission_popup_shown = true;
+
 		pf_flags = PF_BODY_BIG | PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON;
 		choice = popup(pf_flags, 3, POPUP_NO, XSTR( "&Yes, Quit", 28), XSTR( "Yes, &Restart", 29), XSTR( "Do you really want to end the mission?", 30));
 
@@ -1431,6 +1434,7 @@
 		default:
 			break;  // do nothing
 		}
+		quit_mission_popup_shown = false;
 
 		game_start_time();
 		game_flush();
Index: code/io/keycontrol.h
===================================================================
--- code/io/keycontrol.h	(revision 7218)
+++ code/io/keycontrol.h	(working copy)
@@ -21,6 +21,8 @@
 extern int Dead_key_set_size;
 extern bool Perspective_locked;
 
+extern bool quit_mission_popup_shown;
+
 typedef struct button_info
 {
 	int status[NUM_BUTTON_FIELDS];
