Issue with waits, app closing automatically

I am using wait until element is visible and contains element. But I don’t know sometime app is closing automatically when on wait step. If i am using sleep instead of wait it is working fine. What could be the possible fixes that can be done here to stop the app closing?

One more question, what is the different between wait until element is visible and wait until page contains element?