In some circumstances where you cannot use (or open) the task manager panel to see the logged in users on a system and need to terminate a opened session, you might need to know your way around the CLI to achieve this task.
Those simple steps will show you how.
1. Open the Command Prompt or PowerShell console with elevated privileges
2. Enter the following command to list the logged-in users (this command will display users with opened active or disconnected sessions) :
quser
The output will look like this :
C:\Users\jadmin>quser USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME >jdoe rdp-tcp#140 2 Active . 2018-09-07 10:58 AM
3. Then use the “logoff” command with the session ID to terminate the desired user session (example with the output above) :
logoff 2
Now the user should be out of the system, you may use “quser” again to validate.