How to Instantly Log Out of Ubuntu From a Terminal
To log out of Ubuntu desktop session from the command line run the gnome-session-quit command, adding the --no-prompt flag to log out instantly.
This post, How to Instantly Log Out of Ubuntu From a Terminal is from OMG! Ubuntu!. Do not reproduce elsewhere without permission.
Source: OMG! Ubuntu!