Fix session close bug