Fixed a bug with logout

It wasn't quite as stable as originally anticipated. All good now, though.