Also more exit condition so that the simulation will terminate if nan happens or timestep becomes too short.