fix: end the main loop if StdIOSession is closed