Log a user out via Apex when logged in as another user:

delete [Select Id from AuthSession 
        WHERE UsersId =: UserInfo.getUserId() 
        AND SessionType='SubstituteUser'];

Session Types

SESSION TYPE DESCRIPTION
API Created when accessing an org through the API.
APIOnlyUser Created to enable a password reset in the user interface for API-only users.
Aura Created for access to Lightning Experience functionality.
ChatterNetworks Created when using Chatter Networks or Chatter Communities.
ChatterNetworksAPIOnly Created when using the Chatter Networks or Chatter Communities API.
ChatterNetworksAPIOnlyOAuth Created when approving OAuth access by a Chatter Communities user.
Content Created when serving user-uploaded content.
DataDownloadOnly A session that can only be used to download data.
LightningContainerComponent Created for use with Lightning container components.
LivePreview Created to use the live preview functionality in Community Builder.
Node Created for NodeJS access.
OauthApprovalUI A session that allows access only to the OAuth approval page.
Oauth2 Created using OAuth flows. For example, if you use OAuth authentication for a connected app, this type of session is created.
SamlOauthApprovalUi Created when approving OAuth access during a SAML flow.
SiteStudio Created when using the Community Builder user interface.
SitePreview Initiated when an internal canvas app is invoked.
STREAMING_API Created for use by the streaming API.
SubstituteUser Created when one user logs in as another user. For example, if an administrator logs in as another user, a SubstituteUser session is created.
UI Created for access to the Salesforce Classic UI. Represents the core session for a login to the user interface.
UnspecifiedType Created by an unknown source.
UserSite Initiated when a canvas application is invoked.
Visualforce Created to access Visualforce pages.
WDC_API A session using the Work.com API.

Temporary Session Types

TEMPORARY SESSION TYPE DESCRIPTION
TempAuraExchange Created to switch to the Lightning domain.
TempChatterNetworks Created to switch to Chatter Networks or Chatter Communities.
TempContentExchange Created to switch to the content domain, such as the user interface into which users enter their credentials.
TempLccExchange Created to switch to the LCC domain.
TempLivepreviewExchange Created to switch to using the live preview functionality in Community Builder.
TempNodeExchange Created to switch to NodeJS.
TempOauthAccessTokenFrontdoor Created for a user attempting to grant access to an application using the OAuth protocol.
TempSitepreviewExchange Created to switch to using an internal canvas app.
TempSitestudioExchange Created to switch to using the Community Builder user interface.
TempVisualforceExchange Created to switch to the Visualforce domain.
TempUIFrontdoor Created to switch to the Salesforce UI.

https://help.salesforce.com/articleView?id=security_session_types.htm&type=5