more robust logout