diff --git a/plugins/python-loader/py-console.c b/plugins/python-loader/py-console.c
index 9aa03e9..fcfadd4 100644
--- a/plugins/python-loader/py-console.c
+++ b/plugins/python-loader/py-console.c
@@ -19,6 +19,7 @@
 #include <gdk/gdkkeysyms.h>
 #include <glib/gi18n-lib.h>
 
+#include <Python.h>
 #include <stdlib.h>
 #include <string.h>
 typedef enum {
@@ -42,9 +43,18 @@ typedef struct {
 static App *app = NULL;
 
 
+static int
+cb_test_signals (void)
+{
+	if (PyErr_CheckSignals() < 0)
+		gtk_main_quit ();
+	return TRUE;
+}
+
 static gint
 cb_delete_app (GtkWidget *caller, GdkEvent *event, gpointer data)
 {
+	g_idle_remove_by_data (app);
 	app = NULL;
 
 	return FALSE;
@@ -224,6 +234,7 @@ show_python_console (GnmAction const *action, WorkbookControl *wbc)
 			  G_CALLBACK (cb_delete_app), NULL);
 	g_signal_connect (G_OBJECT (app->win), "key_press_event",
 			  G_CALLBACK (cb_key_event), NULL);
+	g_idle_add((GSourceFunc) cb_test_signals, app);
 
 	gtk_widget_show_all (app->win);
 }

