The race riots didn't help, but they were largely secondary to the factories leaving. The UAW would never strike at their factory; they would usually go across the street and strike at some significant, shared plant (like an engine factory for multiple vehicles). For a long time, logistic constraints prevented major auto companies from moving too far away, but once they figured it out they started putting each factory in a new, usually right-to-work state, so you could only strike at your factory. Flint went from being the home of GM and having ~14 major auto factories to 3. Similar story for Detroit.
Similar things happened in most major industries. The other one I'm familiar with is GE Locomotive, who moved their engine facility to Grove City (which still never unionized), and now has a major facility in Fort Worth as well.