Thank you for the help! Yes, I will just have to do some more investigating if and when it happens again. In the meantime I may put in a feature request (or see if there is an existing one) for system.util.endSession( [username], [project], [address], [clientId])
or something to that effect which could do the same thing as me going into the gateway and terminating a session myself.
Edit: Looks like this can be done using existing functions: