Issue where function returned without closing session.