   (let [redraw-chan (chan)
         request-anim #(.requestAnimationFrame js/window %)]
     (letfn [(trigger-redraw []
-              (put! redraw-chan 1)
-              (request-anim trigger-redraw))]
+              (when-not (:quit @state)
+                (put! redraw-chan 1)
+                (request-anim trigger-redraw)))]
       (request-anim trigger-redraw)
       redraw-chan)))
 

              ; force gravity to reset
              (put! pause-grav 0)
              (put! resume-grav 0)
              (recur))))))))

;;------------------------------------------------------------
;; Opponent drawing


(defn cleanup []

  (swap! state assoc :quit true)
  (close! (:quit-chan @state))

  )
