       (.enableLiveMode gui false))
     (let [now (jvm-time-ms)
           wake-time (if (> now (+ target-time 10)) now target-time)]
-      (state-assoc! :last-wake-time wake-time))))
+      (swap! state assoc :last-wake-time wake-time))))
 
 ;; higher level
 

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

    (when-not (empty? z-drive)
      (when (z-stage-needs-adjustment z-drive)
        (let [z (get-z-stage-position z-drive)]
          (swap! state assoc :reference-z z))))))

;; startup and shutdown

