Fix the bug that the program could recover after press the close button