Update terminateSimulation function