Можно так
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
private function closeCurrentSession(TokenStorageInterface $tokenStorage, Request $request)
{
$token = new AnonymousToken('default', 'anon.');
$tokenStorage->setToken($token);
$request->getSession()->invalidate();
throw new AccessDeniedException();
}