better logout detection