While mobs are powerful and wreak intense havoc in a short period of time, they are hard to sustain. Though people feel intense allegiance to them for short periods of time, at heart, the connections between rioters are tenuous and temporary. That's why many riot control tactics employed by police rely on intimidation, rather than actual violence.
Often, the threat of arrest will be enough to break the spell of the mob and cause people to disperse. Rioters tend not to be armed with anything other than what they found at the riot site, so officers with guns, rubber bullets, horses or dogs will be sufficient. Police officers may also use water hoses or odious gases and sprays to deal with stubborn rioters, and of course, some resort to brutal beatings to restore order. During the Arab Spring of 2011, when protests and riots spread throughout the Middle East, participants circulated handbooks that taught their fellow protestors how to withstand such attacks. Law enforcement officials don't attempt to apprehend every single rioter, but they will want to make sure that any leaders who emerged in the course of rioting are effectively subdued, which may require arrest and prosecution.
Once a riot ends, authorities typically see destruction and damage -- not an impetus to change their actions. Only rarely do participants effect social change or gain concessions after their violent outbursts, which may be why riots remain relatively rare. But will we ever be able to prevent them altogether? Governments could use censorship of the media so that riot triggers aren't publicized, but such behavior is unlikely to be tolerated in a democracy. Increasing police forces so that mobs don't have time to whip themselves into a frenzy before enforcement arrives would be helpful, but expensive. Social media could play a role; though the technology does make it easier for would-be rioters to find a place to go, it may also be an effective deterrent as lawyers and officials identify people to arrest and prosecute from pictures and messages. Unfortunately, these measures don't address the underlying issues of class and race that provide the fuel for riots. Perhaps when no one feels unjustly treated, we'll have an end to riots. Of course, then we'll have the flying pigs to deal with.