Fixed exception when quitting app