what broadly happened, up to the final few years of BR steam was that the railways scrapped their own locomotives, at most works there was a "graveyard" siding, where withdrawn locomotives awaited their fate.
In the final years, some 16,000 locomotives were withdrawn, and BR could not cope, so locomotives were sold to independant scrapyards, the most famous of course being Barry.
So a withdrawn locomotive would make its way, often under its own steam to its final destination. Adrian Vaughn recalls in "Signalman's Twilight", that in theory from 1964, most of the WR, and certainly the main line into Paddington should be 100% diesel, but due to failures steam locomotives had to be used, one reason - which still gives me a smile - were electrical faults which were inexplicable until it was realised that the ledge above the instrument console was ideal for the driver's tea can, the sugered tea would slop out and cause a short circuit
One substitute steamer was an absolutely decrepit Hall which was only in steam for its final run to the scrapyard. The crew ran it faster and faster enjoying a last fling until it broke an intermediate valve rod (Signalman's twilight) so presumably this loco was already withdrawn before getting a repreive due to diesel failure. It was so decrepit that it's identity was not noted
Christmas 1966, and the Southern region realised they would be short of motive power, so went to see what other regions had. The report was the SR had scrapped better locos, so it was back to their own scrap queue and a repreive for some withdrawn engines