European countries (mainly Britain, France, and Spain) took over a lot of Africa, and other countries. Some of them, such as Australia abd Canada, are still in some way related to Britain. So what caused Britain and the other countries to come out of Africa? And what prompted the US, Britain, and any other country where it was common, to end slavery?
You are asking two very different things. Slavery ended in the British Empire 140 years before its last African colonies became independent and joined the Commonwealth. Most countries ended slavery at different times for different reasons and some were a lot later than others (Britain was early 19th century Spain was late 19th century), (Also just a small thing to add Spain largely didn't have an influence on Africa at the height of the colonial power. It never regained the height of its power seen in the reigns of Charles I, Philip II and III)
I can't speak to the French as much but essentially in the mid-1800's several British colonies began to agitate for 'dominion' status. This was the country in question being able to control their own internal affairs but still have the Queen as the head of State and the British government largely dictating their foreign policy. This was evident in both Canada and Australia who became dominions but also Ireland which didn't.
World War One saw the British power slip somewhat but they still retain most of their colonies and even expanded them in the Middle East. But independence movements did start to gain momentum in the post war period like in India lead by Gandhi, Nehru and the INC. 1940 saw Britain at its weakest point in over a century and many colonies thought about the future. Some Indians under Bose joined the fascists and fought against the British with the Japanese.
While the UK did recover, part of a condition of allying itself in the war with the US in 1941 is that it wouldn't try and stop its colonies becoming independent. Roosevelt was a strong anti-imperialist and made it a condition of the Atlantic Charter with Churchill.
After the war the British simply didn't have the resources to maintain its empire. It's also seemed hypocritical to many of its subjects to fight in a war for 'freedom' but without being able to determine the future of their countries when they returned home. So after the war the dominoes began to fall with Britain 'jewel' India gaining independence in 1947 (also Pakistan was created). Many countries followed suit but were reorganised into the Commonwealth. They would recognise King George VI as Sovereign but he would have little real power.
This was in 1949 and while it did change much, neo-colonialism started to take hold. Most of these colonies were maintained by British workers (in the administration level not manual) and its systems were based on British models. Many of them remained in the Commonwealth countries and they didn't begin to get total independence until the 1960's with most of the African countries finally breaking away. Countries like Egypt were technically independent but had U.K. Puppets in control who had been bribed by U.K. Corporations. The retaking of the Suez Canal by the Egyptians was a huge rebuttal of this neo-colonialism. Other examples were Pakistan and India having British officers organising both their armies despite being in conflict with one another.
And still today most of these countries are still in the Commonwealth. Pakistan and India have left but Jamaica, Australia, Canada, Kenya etc are all still members.
The difference with the French (and probably why they don't have any real ties to their former colonies) is that they tried to re-subjugate them by force. The Free French had been ousted by the Nazi's in 1940 and the Vichy French collaborators maintained the colonies (with help from the Nazi's and Japanese).
To reassert their power after the war the Free French tried to destabilise their empire. However several resistance movements had fought the Vichy and were not willing to accept French rule such as the Viet Minh under Ho Chi Minh. The French re-occupation saw guerrilla movements spring up in places like Algeria and Vietnam eventually forcing the French to leave the countries for good. Vietnam only became truly independent in the North while Algeria became fully independent.
^I am just underlying this to show you why the British still have ties to their former colonies and the French largely don't.