The answer is dependent on context I think.
In a universe where the whole future of the world is laid out before you and you can choose 1 death or many deaths, then sure, pick the greater good.
The weakness of simplistic “greater good” automatic arguments is that in a real universe it opens you up to manipulation.
In the end, there’s no avoiding thinking through the incentives from all perspectives. And that indeed suggests not giving in to the rioters, to protect the integrity of the entire legal system and reduce the risk that every trial becomes a show trial dictated by whoever has the biggest mob.
Watch the music video “Let’s go” by stuck in the sound for another take on exactly this scenario.
https://youtu.be/52Gg9CqhbP8?si=fKzjWGeAXE1S7D2f