Signal to stop, as in The police were flagging down all cars. This expression uses the verb flag in the sense of "catch the attention of, as by waving a flag," a usage dating from the mid-1800s; down was added in the first half of the 1900s.
To signal something or someone to stop: I flagged down a taxi when it started raining. When we ran out of gas, we flagged the police officer down to ask for help.