--- /tmp/pan-0.107/pan/gui/pan.cc	2006-08-08 00:54:41.000000000 -0500
+++ ./pan.cc	2006-08-08 21:49:48.000000000 -0500
@@ -18,6 +18,7 @@
  */
 
 #include <config.h>
+#include <signal.h>
 extern "C" {
   #include <glib/gi18n.h>
   #include <gtk/gtk.h>
@@ -48,6 +49,33 @@
     return true; // don't invoke the default handler that destroys the widget
   }
 
+  void sighup_handler (int unused)
+  {
+    signal (SIGHUP, sighup_handler); // reset signal
+    std::cerr << LINE_ID << std::endl;
+    gtk_main_quit ();
+  }
+
+  void sigint_handler (int unused)
+  {
+    signal (SIGINT, sigint_handler); // reset signal
+    std::cerr << LINE_ID << std::endl;
+    gtk_main_quit ();
+  }
+
+  void sigquit_handler (int unused)
+  {
+    std::cerr << LINE_ID << std::endl;
+    gtk_main_quit ();
+  }
+
+  void register_shutdown_signals ()
+  {
+    signal (SIGHUP, sighup_handler);
+    signal (SIGINT, sigint_handler);
+    signal (SIGQUIT, sigquit_handler);
+  }
+
   void destroy_cb (GtkWidget*w, gpointer user_data)
   {
     gtk_main_quit ();
@@ -108,6 +136,7 @@
         g_signal_connect (w, "destroy", G_CALLBACK(add_grouplist_task), foo);
       }
 
+      register_shutdown_signals ();
       gtk_main ();
       g_signal_handler_disconnect (window, delete_cb_id);
     }
@@ -225,9 +254,11 @@
         gtk_widget_show_all (w);
         g_signal_connect (w, "destroy", G_CALLBACK(destroy_cb), 0);
         g_signal_connect (G_OBJECT(w), "delete-event", G_CALLBACK(delete_event_cb), 0);
+        register_shutdown_signals ();
         gtk_main (); // FIXME: never exits when task pane user hits 'close'
       } else {
         GMainLoop * main_loop = g_main_loop_new (NULL, false);
+        register_shutdown_signals ();
         g_main_loop_run (main_loop); // FIXME g_loop_quit when queue.empty()
         g_main_loop_unref (main_loop);
       }
