           (socket/emit "update-player" {:theme (:theme @state) :board (drawable-board)}))
 
         ; quit or schedule another update
-        (let [quit (:quit-chan @state)
+        (let [quit quit-chan
               [_ ch] (alts! [quit (timeout 16)])]
           (when-not (= ch quit)
             (recur data)))))))

  (go-loop []
    (let [speed (grav-speed (:level @state) (:soft-drop @state))
          time- (timeout speed)
          quit (:quit-chan @state)
          [_ c] (alts! [time- stop-grav quit])]
      (when (= c time-)
        (apply-gravity!)
        (recur)))))


(defn cleanup []
  (swap! state assoc :quit true)
  (if quit-chan
    (close! quit-chan))

  (socket/removeListener "set-state"))
