=== modified file 'sql/mysqld.cc'
--- sql/mysqld.cc	2014-06-11 21:13:03 +0000
+++ sql/mysqld.cc	2014-06-14 08:15:43 +0000
@@ -5173,6 +5173,19 @@
 
 void wsrep_close_applier_threads(int count)
 {
+  if (!wsrep_connected)
+  {
+    /* see wsrep_replication_start() for the logic */
+    if (wsrep_cluster_address && strlen(wsrep_cluster_address) &&
+        wsrep_provider && strcasecmp(wsrep_provider, "none"))
+    {
+      WSREP_ERROR("Trying to stop slave threads before creating "
+                  "connection at '%s'", wsrep_cluster_address);
+      assert(0);
+    }
+    return;
+  }
+
   THD *tmp;
   mysql_mutex_lock(&LOCK_thread_count); // For unlink from list
 
@@ -5185,12 +5198,20 @@
     if (tmp->wsrep_applier)
     {
       WSREP_DEBUG("closing wsrep applier thread %ld", tmp->thread_id);
-      tmp->wsrep_applier_closing= TRUE;
       count--;
+      wsrep_running_threads--;
+      end_connection(tmp);
+      it.remove();
     }
   }
 
+  WSREP_DEBUG("wsrep running threads now: %lu", wsrep_running_threads);
+  mysql_cond_broadcast(&COND_thread_count);
   mysql_mutex_unlock(&LOCK_thread_count);
+  if (count) {
+    WSREP_ERROR("Trying to stop wsrep applier threads however only "
+                "fell short by %d", count);
+  }
 }
 
 void wsrep_wait_appliers_close(THD *thd)

=== modified file 'sql/sql_class.cc'
--- sql/sql_class.cc	2014-04-16 09:13:43 +0000
+++ sql/sql_class.cc	2014-06-14 07:46:47 +0000
@@ -998,7 +998,6 @@
    spcont(NULL),
 #ifdef WITH_WSREP
    wsrep_applier(is_applier),
-   wsrep_applier_closing(FALSE),
    wsrep_client_thread(0),
    wsrep_apply_toi(false),
 #endif

=== modified file 'sql/sql_class.h'
--- sql/sql_class.h	2014-04-16 09:13:43 +0000
+++ sql/sql_class.h	2014-06-14 07:47:31 +0000
@@ -2357,7 +2357,6 @@
 
 #ifdef WITH_WSREP
   const bool                wsrep_applier; /* dedicated slave applier thread */
-  bool                      wsrep_applier_closing; /* applier marked to close */
   bool                      wsrep_client_thread; /* to identify client threads*/
   enum wsrep_exec_mode      wsrep_exec_mode;
   query_id_t                wsrep_last_query_id;

=== modified file 'sql/sql_list.h'
--- sql/sql_list.h	2014-03-11 18:07:02 +0000
+++ sql/sql_list.h	2014-06-14 08:12:20 +0000
@@ -751,6 +751,16 @@
     el= &current->next;
     return current;
   }
+  void remove(void)
+  {
+    if (current == list->first || current == 0) {
+      list->empty();
+      el = &list->first;
+    } else {
+      el=&current->next;
+      current->unlink();
+    }
+  }
 };
 
 

=== modified file 'sql/wsrep_var.cc'
--- sql/wsrep_var.cc	2014-02-04 03:55:46 +0000
+++ sql/wsrep_var.cc	2014-06-14 06:46:56 +0000
@@ -465,6 +465,9 @@
   {
     wsrep_create_appliers(wsrep_slave_count_change);
     wsrep_slave_count_change = 0;
+  } else if (wsrep_slave_count_change < 0) {
+    wsrep_close_applier_threads(-wsrep_slave_count_change);
+    wsrep_slave_count_change = 0;
   }
   return false;
 }

