Improve session handling at logout

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>