Slavery did not 'die out' in either Cuba or Brazil. It was ended by governmental order in both cases and in both cases over the objection of the slave holders themselves.
Slavery died out in Brazil when a couple of Brazilian states banned it. Slaves in the other states then ran away en masse and the enforcement costs exceeded the economic utility. The whole system rapidly collapsed - as would have happened in the seceding states had Lincoln not started a war to impose federal government rule on them. None other than Lincoln pointed out this is what would have happened to slavery in those states without the benefits and protections of the Fugitive Slave Clause in the US Constitution.