fixed the unable to exit bug