fix a bug when quiting