Way to logout a user from the command line in OS X 10.9
sudo launchctl bootout gui/$(id -u &lt;username&gt;)
or
sudo launchctl bootout user/$(id -u &lt;username&gt;)

Replace username with the target user's user name or replace the whole subshell with the user's uid.  This tells launchctl to teardown the users login session (gui specifically refers to the user's temporary login session, user specifies the users background processes).

You can log yourself out without the sudo to test this.

Note that this will ONLY work on macOS 10.11.x or newer (see launchctl help for more)