Did the kid bring a note? The parent needs to send a note or talk to an administrator by phone. The school usually gives the kid a pass of some kind to leave. I doubt this happened with all of these kids. Truant.
Note or not, police have no authority to prevent anyone from leaving a school. This is a free country. Technically, like I said, they can arrest a kid who is AWOL from school, but that means actually picking up a kid once he's outside the school area, not blocking the exits.
And, like I said, I don't think 16- or 17-year-olds and certainly not 18-year-olds can be picked up for truancy. All those students should be free to go wherever they want - if the school has a problem with that they're free to expel the kid for breaking the rules. But they commit no crime by leaving the school.
Yeah, most of them probablly are truant, or would be if allowed to leave the grounds, but pepper spray to combat truancy seems like overkill.