What might have been done to help African nations transition to self-rule peacefully?
The European countries could have done much more to help Africa transition to self rule, but this relies on the assumption Europeans wanted to invest substantially in the effort. Africa was not prepared for self rule on any level and Europeans needed to make better transition plans. This proved to be too much of a financial commitment for countries that were economically ravaged by World War II.
Economically, the continent of Africa had been drained of its resources. European powers converted many of the agricultural industries to cash crops, making it difficult for African countries to be self sufficient in terms of food production. The European powers could have worked to transition the agriculture industries away from cash crops and towards foods that could sustain their population.
Europeans improved the transportation infrastructure to aid the import of natural resources back to the home colonies. No efforts were made to modernize Africa in terms of manufacturing or industry. Before granting Africans self rule, efforts could have been made to modernize industry. An effort could have been made in that area that would have been mutually beneficial. Along with the transition to industry, a trained labor force would be needed. Europeans could have created vocational education centers to train African laborers for jobs in industry.
When the colonial powers left Africa, they left behind a power vacuum. Years of indirect rule had not prepared Africans to represent all of the people. Efforts in the area of political and legal education should have been made for self governance. Europeans should have worked with African leaders to draw boundaries that took into account ethnic and political rivalries. Many smaller states would have been more effective than large states that were ethnically and culturally diverse. A transition period of ten years should have been established with Western style representative governments being established in countries with homogeneous ethnic identities.
All of these things assume that Europeans had a monetary and moral stake in rebuilding a continent that it had greatly harmed. No such commitment seems to have existed in the decades after World War II, when African states gained their independence.