                                 (println "Exception in Quil draw-fn for sketch" title ": " e "\nstacktrace: " (with-out-str (print-cause-trace e)))
                                 (Thread/sleep 1000))))
         draw-fn           (if (:safe-draw-fn options) safe-draw-fn draw-fn)
-        on-close-fn       (or (:on-close options) (fn [] nil))
+        on-close-fn       (or (:on-close options) no-fn)
         state             (atom nil)
         target-obj        (atom nil)
         looping?          (atom true)
         listeners         (into {} (for [name listeners]
-                                     [name (or (options name) (fn [] nil))]))
+                                     [name (or (options name) no-fn)]))
         applet-state      (merge options
                                  {:state state
                                   :target-obj target-obj


(generate-listeners)

(defn wrap-mouse-wheel
  "Wraps callback to an instance of java.awt.event.MouseEventListener
  or returns nil if given callback is nil."
  [mouse-wheel applet]
  (when mouse-wheel
    (reify java.awt.event.MouseWheelListener
      (mouseWheelMoved [this e]
        (with-applet applet
          (mouse-wheel (.getWheelRotation e)))))))

(defn applet
  "Create and start a new visualisation applet.

        target            (validate-target! (:target options))
        title             (or (:title options) (str "Quil " (swap! untitled-applet-id* inc)))
        renderer          (or (:renderer options) :java2d)
        draw-fn           (or (:draw options) no-fn)
        output-file       (validate-output-file! renderer (:output-file options))
        target            (if (empty? output-file) target :none)
        setup-fn          (or (:setup options) no-fn)
        safe-draw-fn      (fn []
                            (try
                              (draw-fn)
