diff --git a/src/server/e-ews-connection.c b/src/server/e-ews-connection.c
index 5369c83..c5ced90 100644
--- a/src/server/e-ews-connection.c
+++ b/src/server/e-ews-connection.c
@@ -694,6 +694,15 @@ ews_create_folder_cb (ESoapParameter *soapparam, EwsNode *enode)
 }
 
 static void
+do_kill_soup_session (EEwsConnectionPrivate *priv)
+{
+	g_object_unref (priv->soup_session);
+	priv->soup_session = NULL;
+
+	g_main_loop_quit(priv->soup_loop);
+}
+
+static void
 e_ews_connection_dispose (GObject *object)
 {
 	EEwsConnection *cnc = (EEwsConnection *) object;
@@ -720,10 +729,18 @@ e_ews_connection_dispose (GObject *object)
 	g_signal_handlers_disconnect_by_func	(priv->soup_session, ews_connection_authenticate, cnc);
 
 	if (priv->soup_session) {
-		g_object_unref (priv->soup_session);
-		priv->soup_session = NULL;
-
-		g_main_loop_quit(priv->soup_loop);
+		GSource *source;
+
+		/* FFS. We can't even *unref* the soup session object from
+		   anywhere other than its own context.
+		   https://bugzilla.gnome.org/show_bug.cgi?id=665801 */
+		source = g_idle_source_new ();
+		g_source_set_priority (source, G_PRIORITY_HIGH);
+		g_source_set_callback (source, do_kill_soup_session,
+				       priv, NULL);
+		g_source_attach (source, priv->soup_context);
+
+		/* Wait for do_kill_soup_session() to kill the mainloop */ 
 		g_thread_join(priv->soup_thread);
 		priv->soup_thread = NULL;
 
