improved session closure