Fix triggering of afterrun event.