If an enforcement officer exercises a power to stop or search a vehicle, the enforcement officer may require the vehicle to remain stopped for as long as is reasonably necessary for the purposes of the stopping or to undertake the search.