This article explains how to log out of X (formerly Twitter) and switch accounts on desktop and mobile. It also covers how to log out of all sessions of the site.
How to log out of X (Twitter) account
Logging out of X on the website is easy if you know where to look. (The button is easy to miss.) Here's how.
Under the menu on the left, under the Post button, you will see your profile picture, account name, and username.
Click on the menu with the three dots next to it.