Dispersing violent crowds is typically a task for the police, although widespread rioting may require military support. One reason unstable countries typically have paramilitary forces is because without them, rioting would be a daily occurrence.
Deadly force is used in some repressive countries to stop riots, particularly if martial law is declared or in a country at war. This is generally permissible under the laws of war so long as nonparticipating civilians are not intended targets. Collateral damage is a usual result.