I would like to call a function just before emacs exits. Normally the following can do job:

(add-hook 'kill-emacs-hook 'my-function)

Unfortunately when I shutdown the system (MS Windows) or terminating the emacs process by some external tools, this does not work.

Is it impossible to achieve this goal in such situations?


The manual explicitly states that kill-emacs is called, running the kill-emacs-hook, when SIGTERM or SIGKILL is recieved. So I would call this a bug.


(I guess this has to do with how windows kills differently than POSIX, but it should be possible to implement the analog/correct behaviour.)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.