Extend error handling to closeSession