Fixed input/output error when attempting to quit in some cases