LM317 Train Power Supply
The LM317 is a linear regulator, which is really inappropriate for significant power, like what a model train requires.  You say the train draws 300 mA.  That means at 3.3 V drop accross the regulator it would dissipate 1 W, which would require a heatsink.

I'm not sure why your regulator is dying.  I thought (haven't checked) that the LM317 has integrated thermal shutdown, so it should shut itself off if overheated.  Perhaps it doesn't.  Check the datasheet.

In any case, a switching power supply is the right answer.  I am actually working on a product right now for the model train market that includes a track power supply.  I am starting with 48 V.  That gets bucked down to whatever the user selects as the track power supply voltage, then a separate H bridge circuit implements the polarity flipping for the DCC protocol.  I can dump a few Amps onto the track and the board gets warm, but not hot.  Once this becomes a product, the schematic will be made public.  If you really want to see what I have so far, I can make it public unofficially, but I don't like showing internal designs until everything has been worked out and properly tested.

On a separate note, why not use DCC?  That completely gets around the problem of "sending one of the trains in reverse due to the common rail".