Way Back when I was into HO I came up with a way to do this using 2 cheap 3 pole on/off/on switches. And 3 isolated sections of track in between the yard and mainline blocks. I had to stop the train then throw a switch but it prevented any shorts from happening. I use 3 isolated sections of track in A row each one slightly larger than my longest loco.
The 2 switches were mounted side by side. Then I drilled a small scrap of wood so it would slide down over both switch levers at the same time and glued it in place with hot glue. This insured both switches were always thrown the same way at the same time.
Yard was on Transformer "A" Main Line was on Transformer "B"
Yard, Iso-TK #1, Iso-TK #2, Iso-TK #3, Maim
Switch one pin 1 --Not used
Switch one pin 2 to Iso-TK #1 outer rail
Switch one pin 3 Transformer "A" outer rail
Switch one pin 4 --Not used
Switch one pin 5 to Iso-TK #1 inner rail
Switch one pin 6 Transformer "A" inner rail
Switch one pin 7 Transformer "B" outer rail
Switch one pin 8 to Iso-TK #2 outer rail
Switch one pin 9 Transformer "A" outer rail
Switch two pin 1 Transformer "B" inner rail
Switch two pin 2 to Iso-TK #2 inner rail
Switch two pin 3 Transformer "A" inner rail
Switch two pin 4 Transformer "B" outer rail
Switch two pin 5 to Iso-TK #3 outer rail
Switch two pin 6 --Not used
Switch two pin 7 Transformer "B" inner rail
Switch two pin 8 to Iso-TK #3 inner rail
Switch two pin 9 --Not used
When wired up
switches thrown right transformer "A" powered: yard , Iso-TK #1, Iso-TK #2, and Iso-TK # 3 is dead
switches thrown Left transformer "B" powered: main , Iso-TK #3, Iso-TK #2, and Iso-TK # 1 is dead
The plan was to stop the loco on Iso-TK 2
but if the loco's momentum carried it 1/2 way into the next power district. always having one section Dead Iso-TK #1 or Iso-TK #3 their is no chance of it shorting because the loco was not long enough to be able to make contact with both power districts at the same time.
I know it sounds complicated but it worked for me back when TYCO trains and slot cars were the toys all the cool kids wanted