session not being closed bug fix