Fix app closing issue