fix a bug in exit