fix unclean shutdown bug