add functions for safely exiting the emacs daemon