There were jubilant scenes in the conference centre after South Africa’s leader formally closed the summit