fixed history bug when exiting with ctrl-c