Fix crash when closing and reopening app
