fixed a bug that cannot close program