Created an endSimulation method