As Matt says, it would very likely take a 'great man' as a general cultural revulsion against the slave trade would be unlikely. It is so *profitable*...
By 1650, the impact of the slave trade was such that an intelligent ruler might connect the dots and try to stop it. A law to prohibit the sale of slaves to foreigners is quite feasible. Enforcement would be difficult, of course (When the Brits tried it post-1807, the economies of many coastal states all but collapsed), but if we posit someone matching Shaka in ruthlessness, why not? It's better to be poor than tied to a stake and disembowelled alive by hyenas, I guess.
The European reaction would be fierce, though, and it would have all the righteous ire of good capitalists deprived of a source of revenue behind it. I doubt any European nation would actually put large numbers of regular troops on equatorial African soil before 1800 (it was a big gamble even then), but quiet support to an opposing ruler could turn the tide easily enough. THe law would have to have been passed at a time when the state in question controlled practically the entire territory in question. I doubt the European powers (whom contrary to popular myth, were well aware of the cultures and politics of West Africa) would have allowed that to happen, and a ruler rising in spite of their opposition would have to be incredibly skilled and lucky.
BTW, I was told that the Asante stopped the export of slaves from the then Gold Coast (modern Ghana) for a while. This was towards the end of the slave trade and affected no large area, but it was done. Of course they wanted them for their own fields and for human sacrifice, so I'm not sure it was significantly better, but still...