fix session close bugs