Fixes unexpected session end issue.