Slavery ended because human beings (the slaves) made it end. They revolted constantly, and the threat of revolt wasn't worth the money savings. No European wanted another Hati, so that was the beginning of the end. In the case of the US, after the Civil War had begun, slaves fled to the Union camps in large numbers, which forced the Union to emancipate and enlist them.
Anyway, capitalism doesn't have human values. Nor do nations. Human beings have human values, and we have to band together to impose those values on the various collectives that oppress us… but then because we've banded together, that band becomes the new form of oppression! So it goes.
Machines don't make you stop doing slavery. If anything, the forces go the other way: slavery was dying in the US at the end of the 1700s (slavery had been legal in the North too but was being abolished slowly) then the cotton gin made it suddenly hugely profitable in the South and gave it a big boost.
Anyway, capitalism doesn't have human values. Nor do nations. Human beings have human values, and we have to band together to impose those values on the various collectives that oppress us… but then because we've banded together, that band becomes the new form of oppression! So it goes.