fix a bug

fix a bug that exit will raise an exception if a file is unsaved