How to clock-out current org-task before exit from Emacs? I tried
(add-hook 'kill-emacs-hook #'org-clock-out)
But if there is no current active tasks, Emacs says "No active clock" instead of exit. If there is an active task, in reality clock-out does not occur and the next time when I'm trying to make org-clock-in, see the proposal to resolve the conflict.
(add-hook 'kill-emacs-hook (lambda () (org-clock-out nil t)))
. See the doc string fororg-clock-out
for the meaning of the parameters. I don't know why it does not clock out on exit though: you might want to edebug it and see if it does get called when you kill emacs.