That's obviously difficult. The actual situation is even more difficult: you have to simultaneously deal with the supply and demand factors.
It's not enough just to legalize everything (which will never happen, 80-90% of the globe will never do such a thing under any circumstances, regardless of what the US does). If you do that, the demand will of course still be there. Someone has to wipe out the cartel production/supply by competing with it.
So the US has to go into the production business for cocaine, heroin, etc. It wouldn't be reliable to leave it to Mexico, it would be too easy for the cartels to hijack and control.
Any country that doesn't legalize globally - which will be most of them - will still remain a target for the cartels to sell into. Latin American cartel networks are effective enough and big enough now that they move product globally.
Legalize it all requires that a very large portion of all countries go in on that. It will never happen.
The US will fully legalize marijuana and it will hardly make a dent in taking down the cartels or reducing cartel violence in Latin America, which demonstrates their considerable staying power. There was widespread opinion that it would make a big difference, in reality it'll have hardly made any difference (Mexico is more violent now than it has ever been in its history).