Application closes when phone is going to sleep

i have changed something in my app, i dont know what exactly but it is being closed everytime my phone is going to sleep after some seconds, how can i check what is going on inside of my app when phone is asleep? how can i inspect this?