If you want to logout another macOS user entirely from the console, it’s sufficient to kill the loginwindow process:

pkill -9 -u <user> loginwindow

Seems that loginwindow traps SIGTERM, so we have to use SIGKILL and any unsaved work may be lost. But who cares, we did it without leaving the terminal, which is much more important!

(As seen on Ask Different)