as soon as you smell that food is burning, you instantly remove the pot from the burner, stop the temptation of stirring the food anymore and right way pour the food into another container, ideally into a ceramic bowl (dont use spoon to remove any more food from the original pot, just let the natural flow of food do its job, that will prevent andy stuck food to be transferred to the new pot). To further stop the cooking process, put the ceramic bowl (with lid off if possible) in a sink full of cold water.
That will possibly salvage your remaining food.