Fixing the issue where the scanner is giving error during exit.