Checking on application state to prevent endless animations in the background