One of the answers suggested pkill -TERM emacs
, which does the job but apparently not gracefully.
Notwithstanding that I would recommend using the process ID rather than pkill
, that should be a graceful shut-down. The manual says:
The ‘kill-emacs’ function is normally called via the higher-level
command ‘C-x C-c’ (‘save-buffers-kill-terminal’). *Note
(emacs)Exiting::. It is also called automatically if Emacs receives a
‘SIGTERM’ or ‘SIGHUP’ operating system signal (e.g., when the
controlling terminal is disconnected), or if it receives a ‘SIGINT’
signal while running in batch mode (*note Batch Mode::).
This behaviour was introduced in Emacs 24.1 (which post-dates the Q&A you've linked to).
** Exiting changes
*** Emacs now calls `kill-emacs' if it receives SIGTERM or SIGHUP,
or if it receives a SIGINT signal in batch mode.
*** `kill-emacs-hook' is now also run in batch mode.
Third-party code which adds to `kill-emacs-hook' should check if they
do the right thing in batch mode.
As to why you wouldn't want a non-graceful shutdown, that's not really an Emacs question. Killing processes without allowing them any chance to clean up should always be a last resort. It's not difficult to imagine the problems which might result if a process was killed in the middle of writing a file, for instance.