From https://www.virtualgyanis.com/post/how-to-logoff-kill-remote-desktop-sessions
Start a command prompt with admin permissions.
qwinsta /server:[ServerIP/Hostname]
Example:
qwinsta /server:192.168.40.1
qwinsta /server:myServer.Contoso.com or myserver.contoso.local
Output of Command
C:>qwinsta /server:myServer.contoso.com
SESSIONNAME USERNAME ID STATE TYPE DEVICE
0 Disc rdpwd
ica-tcp 65536 Listen wdica
rdp-tcp 65537 Listen rdpwd
console 16 Conn wdcon
ica-tcp#966 avijitd 10 Active wdica
ica-tcp#969 deepakk 1 Active wdica
rwinsta [Session ID] /server:[Server IP]
Example: We will kill/logoff the remote session of user "avijitd" whose session ID is "10"
rwinsta 10 /server:192.168.40.1
rwinsta 10 /server:myServer.Contoso.com or myserver.contoso.local