Fix app close issue