private function setImpersonatedLogout()
	{
		$token = System::getContainer()->get('security.token_storage')->getToken();

		if (!$token instanceof TokenInterface)
		{
			return;
		}

		$impersonatorUser = null;

		foreach ($token->getRoles() as $role)
		{
			if ($role instanceof SwitchUserRole)
			{
				$impersonatorUser = $role->getSource()->getUsername();
				break;
			}
		}

		if (!$impersonatorUser)
		{
			return;
		}

		$request = System::getContainer()->get('request_stack')->getCurrentRequest();

		if ($request === null)
		{
			throw new \RuntimeException('The request stack did not contain a request');
		}

		$firewallMap = System::getContainer()->get('security.firewall.map');

		// Generate the "exit impersonation" path from the current request
		if (($firewallConfig = $firewallMap->getFirewallConfig($request)) === null || ($switchUserConfig = $firewallConfig->getSwitchUser()) === null)
		{
			return;
		}

		// Take the use back to the "users" module
		$arrParams = array('do' => 'user', urlencode($switchUserConfig['parameter']) => SwitchUserListener::EXIT_VALUE);

		$this->Template->logout = sprintf($GLOBALS['TL_LANG']['MSC']['switchBT'], $impersonatorUser);
		$this->Template->logoutLink = System::getContainer()->get('router')->generate('contao_backend', $arrParams);
	}