   (try
     (attempt-all
       (log "cleanup")
-      (state-assoc! :finished true :display nil)
+      (swap! state assoc :finished true :display nil)
       (when (core isSequenceRunning)
         (core stopSequenceAcquisition))
       (stop-trigger)


(defn interruptible-sleep [time-ms]
  (let [sleepy (CountDownLatch. 1)]
    (state-assoc! :sleepy sleepy :next-wake-time (+ (jvm-time-ms) time-ms))
    (.await sleepy time-ms TimeUnit/MILLISECONDS)))

(defn acq-sleep [interval-ms]

;; globals

(def ^:dynamic state (atom {:stop false}))

(def attached-runnables (atom (vec nil)))

