[WO-587] implement user logout

The following code block didn't changed. I just moved it up in the file to make the order of execution clearer.