Structured logout functionality