title: Emacsclient hook on kill
body: <p>I am trying to find a hook in Emacs, which should fire right before emacs server graceful shutdown.
  I tried kill-emacs-query-functions, kill-emacs-hook, server-done-hook with elisp like :</p>
  
  <pre><code>(add-hook 'server-done-hook
            '(lambda ()
               (savehist-save)
               )
            )
  </code></pre>
  
  <p>... but none of them is called when OS shuts down, so history is not saved.</p>
  
  <p>Maybe someone could give a hint?</p>
  
  <p>P.S. I am on Gentoo Linux, emacs-vcs-23.2.9999 package, terminal only. For testing desired behaviour Emacs is stopped using start-stop-daemon utility.</p>