Index: agent/seahorse-agent.c
===================================================================
--- agent/seahorse-agent.c	(revision 2603)
+++ agent/seahorse-agent.c	(working copy)
@@ -143,11 +143,11 @@
     return TRUE;
 }
 
-void
-seahorse_agent_uninit ()
+gboolean
+seahorse_agent_uninit (gpointer *data)
 {
     if(!seahorse_agent_enabled)
-        return;
+        return TRUE;
 
     /* If any windows are open this closes them */
     seahorse_agent_prompt_cleanup ();
@@ -157,5 +157,7 @@
     seahorse_agent_cache_uninit ();
     seahorse_agent_actions_uninit ();
     seahorse_agent_io_uninit ();
+    
+    return FALSE;
 }
 
Index: agent/seahorse-agent-main.c
===================================================================
--- agent/seahorse-agent-main.c	(revision 2603)
+++ agent/seahorse-agent-main.c	(working copy)
@@ -239,6 +239,8 @@
 
     gtk_init_with_args (&argc, &argv, _("Encryption Key Agent (Seahorse)"), (GOptionEntry *) options, GETTEXT_PACKAGE, NULL);
 
+    gtk_quit_add (0, (GtkFunction*) seahorse_agent_uninit, NULL);
+
     seahorse_agent_prefork ();
 
     if (seahorse_agent_execvars && 
@@ -269,7 +271,7 @@
     seahorse_gtkstock_init ();
     
     if (!seahorse_agent_init ())
-        seahorse_agent_uninit ();
+        agent_quit = TRUE;
     
     /* Sometimes we've already gotten a quit signal */
     if(!agent_quit) {
@@ -279,7 +281,7 @@
     }
 
     /* And now clean them all up */
-    seahorse_agent_uninit ();
+    seahorse_agent_uninit (NULL);
 
     return 0;
 }
Index: agent/seahorse-agent.h
===================================================================
--- agent/seahorse-agent.h	(revision 2603)
+++ agent/seahorse-agent.h	(working copy)
@@ -54,7 +54,7 @@
 
 /* Called in the new child process */
 gboolean seahorse_agent_init ();
-void seahorse_agent_uninit ();
+gboolean seahorse_agent_uninit (gpointer *data);
 
 /* Global options to set from the command line */
 extern gboolean seahorse_agent_cshell;
