diff --git a/agent/seahorse-agent-main.c b/agent/seahorse-agent-main.c
index 0b46542..d419c1a 100644
--- a/agent/seahorse-agent-main.c
+++ b/agent/seahorse-agent-main.c
@@ -240,7 +240,8 @@ int main(int argc, char* argv[])
     gtk_init_with_args (&argc, &argv, _("Encryption Key Agent (Seahorse)"), (GOptionEntry *) options, GETTEXT_PACKAGE, NULL);
 
     gtk_quit_add (0, (GtkFunction) seahorse_agent_uninit, NULL);
-
+    atexit (seahorse_agent_exit);
+    
     seahorse_agent_prefork ();
 
     if (seahorse_agent_execvars && 
diff --git a/agent/seahorse-agent.c b/agent/seahorse-agent.c
index 2224d33..b2a6f6d 100644
--- a/agent/seahorse-agent.c
+++ b/agent/seahorse-agent.c
@@ -161,3 +161,8 @@ seahorse_agent_uninit (gpointer *data)
     return FALSE;
 }
 
+void
+seahorse_agent_exit ()
+{
+    seahorse_agent_uninit (NULL);
+}
diff --git a/agent/seahorse-agent.h b/agent/seahorse-agent.h
index faeb152..92267a9 100644
--- a/agent/seahorse-agent.h
+++ b/agent/seahorse-agent.h
@@ -55,6 +55,7 @@ void seahorse_agent_childsetup ();
 /* Called in the new child process */
 gboolean seahorse_agent_init ();
 gboolean seahorse_agent_uninit (gpointer *data);
+void     seahorse_agent_exit ();
 
 /* Global options to set from the command line */
 extern gboolean seahorse_agent_cshell;
