Are you unaware into how much effort Britain, once it had ceased involvement in the slave trade, then put into stopping that trade not only where they had been involved (in West Africa) but also where they hadn't been (East Africa) as well? Not only did the Royal Navy assign ships specifically for this purpose (despite the serious risk to their crews from tropical diseases), but some of the military expeditions that "progressive thinkers" nowadays label as "nothing but Imperialist aggression" were also for thepurpose of ending Slavery. For example, the last King of Benin (which was a state in coastal Nigeria, not the modern nation of that name further west...), whose overthrow has received an increase in publicity in recent years through a campaign to get 'the Benin Bronzes' repatriated from the British Museum, was breaking a treaty by continuing to practice slavery (and human sacrifice!) within his lands, but if he'd kept to the treaty's terms then Britain would also have done so and Benin could have remained just a client-state -- like various others, such as the Hausa emirates in the north or the Fon-dom of Bafut in British Cameroon -- right through until Nigerian independence.
Also, the British withdrawal was due not just to unprofitability as such -- because some areas probably would still have returned a profit despite the costs of occupation -- but to a recognition that local demands for independence were growing too strong for a democracy like Britain to ignore ("A Wind of Change is blowing over Africa") and to the general post-WW2 malaise...