Always close down a session if an error occurs.