Check termination conditions