The gym idea is a good one, because otherwise it puts school officials in a frustrating position.
Schools are hilariously understaffed for the size and hostility of some of the student body they typically deal with. Kids are more or less forced to go and schools are more or less responsible for them for the allotted time they're to be there.
If a kid walks out of school during the day and something happens, blame lands on the school staff.
It's only the fact that the majority of kids are willing to fall into line that makes the whole system work. The staff that's there is able to handle the fires that pop up when they do because 95+% of the kids are willing to sit down and shut up when told to(And peer pressure helps with a chunk of the rest). When you have essentially organized mutiny... things get kind of scary.
So basically there's only about 3 vague options. 1: You lock the kids up and punish any that attempt to do so anyway hard enough it makes an example and pushes kids back in line. Most likely to keep everyone in line, but also invokes a slight risk of rebellion and a loss of respect for teachers and staff. 2: You make it a school sponsored function. Teachers walk their students outside/somewhere. Let them chant some school approved chants a bit. Basically turn it into a pep rally at the risk of students finding it shallow and still walking out. or 3: A middle ground, you admit you can't stop the students, so let them speak out on their own terms, but just try to funnel them into a safe area (like the gym in SalmonGod's situation.) Risking various outcomes again. But this time with even less control over the situation.
I'm not defending parent reactions, because I doubt many of them are viewing it from this angle and probably most just disagree with their kids politics or them showing rebellion of some sort. However I would probably make it clear to any hypothetical children of mine that unless it's a school approved event, they're not to participate. But if they felt strongly about it (and it wasn't simply a "hur hur, let's skip class" deal) I would see if I could find some out of school event I could take them to.
Schools just aren't equipped to deal with that sort of situation and it's unfair to put it on the shoulders of teachers and staff.