Bug fix causing session to be closed earlier than it should be.