implemented auto-stop of the run after a certain number of events