Nutrient recycling and the stability of ecosystems