In Ubuntu Desktop, there's a command to logout immediately, and the user can execute it without being at the login shell:
$ gnome-session-quit --logout --no-prompt
Q. What is the equivalent command in Ubuntu Server, if any?
(I'm aware that
logout at a non-login shell is not allowed, but perhaps there's a different command. The preferred solution logs out gracefully instead of e.g., killing daemons.)