code: def StopHuntIfCrashLimitExceeded(hunt_id):
    
    hunt_obj = data_store.REL_DB.ReadHuntObject(hunt_id)
  
    # Do nothing if the hunt is already stopped.
    if hunt_obj.hunt_state == rdf_hunt_objects.Hunt.HuntState.STOPPED:
      return hunt_obj
  
    if hunt_obj.crash_limit:
      hunt_counters = data_store.REL_DB.ReadHuntCounters(hunt_id)
      if hunt_counters.num_crashed_clients >= hunt_obj.crash_limit:
        # Remove our rules from the forman and cancel all the started flows.
        # Hunt will be hard-stopped and it will be impossible to restart it.
        reason = ("Hunt %s reached the crashes limit of %d "
                  "and was stopped.") % (hunt_obj.hunt_id, hunt_obj.crash_limit)
        StopHunt(hunt_obj.hunt_id, reason=reason)
  
    return hunt_obj
docs: Stops the hunt if number of crashes exceeds the limit.