The Dutch had established some colonies and forts in what is now Ghana and the Cape Colony in South Africa in the 1600s and continued to hold them in the 1700s.
However, when Napoleon annexed the Netherlands into his French Empire in the early 1800s, Britain took over all of the Dutch overseas colonies, to keep them from becoming part of the French colonial empire.
When Napoleon was defeated in 1815, Britain returned many of the colonies to the Netherlands. However, the Cape Colony was not returned, and continued to be a British colony.
That left Elmina and other Dutch forts on the Gold Coast (now Ghana) as the only Dutch foothold on the continent. The economy of these forts had heavily relied on exporting slaves to the new world in the 1700s. But, when the British abolished the trade of slaves to their Caribbean colonies in 1807, they also put substantial pressure on the Dutch to outlaw the practice too.
So, after 1815, the Dutch Gold Coast had to make an adjustment to "legitimate commerce" which wasn't entirely successful.
In 1850, the British bought out the forts of the Danish Gold Coast, incorporating them into the existing British Gold Coast colony. This meant that there were now British forts interspersed along the same stretch of coast as the Dutch forts. In 1868, the British and Dutch came to an agreement to exchange forts, so that there would be more coherent areas of control.
That didn't really work out, because the Dutch ended up taking control of forts adjacent to Fante territory that was friendly to the British, and the British took control of forts near Asante territory friendly to the Dutch. Only 4 years later, the Dutch ended up concluding that the Gold Coast colony was too costly an investment, and ceded the remaining forts to the British.
So, just as the Scramble for Africa was heating up in the 1870s, the Dutch had divested themselves of colonial possessions in Africa, instead focusing on their colonies in the Caribbean, South America, and the East Indies.