This is a patch adding a query function when exiting Emacs, warning the user if there is a running clock. This is useful for preventing the user from accidentally leaving dangling clocks. I have had success using a modified personal version of this code. My personal version instead prompts the user to clock out and save the buffer. I didn't use it for the patch because it seems a little hacky to me; e.g., kill-emacs-query-functions doesn't mention whether functions can have side effects, and the UI is inconsistent with save-buffers-kill-emacs. The code for my personal version: (add-to-list 'kill-emacs-query-functions (lambda () (if (not (org-clocking-p)) t (if (y-or-n-p "Clock out and save?") (with-current-buffer (marker-buffer org-clock-marker) (org-clock-out) (save-buffer) t) (message "Aborting") nil)))) If there is great demand for this version, I might provide another patch. I have also attached another patch which deduplicates two identical functions that I noticed when preparing the first patch.