         Disconnects all shards.
     */
     public func disconnect() {
-        closed = true
+        func _disconnect() {
+            closed = true
 
-        for shard in shards {
-            shard.disconnect()
+            for shard in shards {
+                shard.disconnect()
+            }
+
+            if connectedShards != shards.count {
+                // Still connecting, say we disconnected, since we never connected to begin with
+                client?.handleEvent("shardManager.disconnect", with: [])
+            }
         }
 
-        if connectedShards != shards.count {
-            // Still connecting, say we disconnected, since we never connected to begin with
-            client?.handleEvent("shardManager.disconnect", with: [])
-        }
+        shardQueue.async(execute: _disconnect)
     }
 
     /**

        - parameter shardNum: The number of the shard that disconnected.
    */
    public func signalShardDisconnected(shardNum: Int) {
        closedShards += 1

        guard closedShards == shards.count else { return }

        client?.handleEvent("shardManager.disconnect", with: [])
    }
}

        - parameter shardNum: The number of the shard that disconnected.
    */
    public func signalShardConnected(shardNum: Int) {
        func _signalShardConnected() {
            connectedShards += 1

            guard connectedShards == shards.count else { return }

            client?.handleEvent("shardManager.connect", with: [])
        }

        shardQueue.async(execute: _signalShardConnected)
    }

    /**
