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?