   (let [new-state (read-string data-str)]
 
     ; Freeze the game.
-    (if (:quit-chan @state)
-      (close! (:quit-chan @state)))
+    (if quit-chan
+      (close! quit-chan))
 
     ; Merge state with new state data.
     (swap! state merge new-state)

    (.addEventListener js/window "keydown" key-down)
    (.addEventListener js/window "keyup" key-up)

    ; Prevent the player from holding the down-key
    ; for more than one piece-drop.
    ;
    ; The soft-drop state is set to:
    ;   = the state of the down-key when it CHANGES
    ;   = off, after a piece is locked
    (let [uc (unique down-chan)]
      (go-loop []
        (let [[value c] (alts! [(:quit-chan @state) uc])]
          (when (= c uc)
            (swap! state assoc :soft-drop value)
            (refresh-gravity!)
            (recur)))))

    ; Remove key events when quitting
    (go
      (<! (:quit-chan @state))
      (.removeEventListener js/window "keydown" key-down)
      (.removeEventListener js/window "keyup" key-up))))


          (socket/emit "update-player" {:theme (:theme @state) :board (drawable-board)}))

        ; quit or schedule another update
        (let [quit quit-chan
              [_ ch] (alts! [quit (timeout 16)])]
          (when-not (= ch quit)
            (recur data)))))))
