CAS-1389: Logout fails as an error happens when tickets are marked as expired

Updates after Misagh's code review