fixed the program not exiting