Function: save-buffers-kill-terminal

Offer to save each buffer, then kill the current connection.
If the current frame has no client, kill Emacs itself.

With prefix ARG, silently save all file-visiting buffers, then kill.

If emacsclient was started with a list of filenames to edit, then
only these files will be asked to be saved.