Add termination checking