Add termination function