diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 23a4299..744cc9b 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -3560,11 +3560,13 @@ imapx_job_idle_start (CamelIMAPXJob *job,
 	/* Don't issue it if the idle was cancelled already */
 	if (is->priv->idle_state == IMAPX_IDLE_PENDING) {
 		is->priv->idle_state = IMAPX_IDLE_ISSUED;
+		g_mutex_unlock (&is->priv->idle_lock);
+
 		imapx_command_start (is, ic);
 	} else {
+		g_mutex_unlock (&is->priv->idle_lock);
 		imapx_unregister_job (is, job);
 	}
-	g_mutex_unlock (&is->priv->idle_lock);
 	QUEUE_UNLOCK (is);
 
 	camel_imapx_command_unref (ic);
