A laptop that went to sleep mid-session can leave an SSH login hanging on a server for a long time. who still lists it, and so does everything that counts users. I’d rather clean that up properly than hunt for the right PID.
systemd-logind tracks every login as a session with its own ID. List them first:
loginctl list-sessions
loginctl session-status 42
The list shows the session ID, user, TTY and more. session-status gives the details of one session, including its processes and the latest log lines, so you can check that 42 really is the stale one. Then end it:
sudo loginctl terminate-session 42
That kills all processes of the session and frees everything attached to it. To clear out every session of one account in one go, there is sudo loginctl terminate-user alice.
Two caveats. First, it really is all processes: a long job or a tmux server that was started from that login lives in the same session and goes down with it. If something important might still be running there, look at session-status before you press enter. Second, don’t end your own session by accident. Run loginctl session-status without an ID to see which one you are in, and keep in mind that an empty string as the ID means the session that runs the command.
For a gentler approach, loginctl kill-session sends a signal of your choice with --signal= instead of tearing the whole session down.
Further reading: loginctl(1) manual page