As with all statistics, you can make the answer fit your agenda/position.
- If you're a train advocate - the towns died when the trains left
- If you're train hater - the trains left because the towns died
Nothing to do with being an “advocate” or a “hater.” If one does the research (which, granted, I have not, because the history of South Dakota towns isn’t really one of my interests), I’m sure one can actually trace the economic development of towns and railroads in the area.
As Just-Thinking-51 noted, development of a highway could cause railroad service to die. Development of highways can also change the population growth and travel patterns in ways that are unfavorable to the small towns the railroads serve. Same with other technology and infrastructure, which may have been more readily available in cities than in small towns whose primary way in/out was the railroad.
And yes, there probably were a few places that only existed because 120 years ago you needed a place to service steam locomotive, but otherwise, there was no real reason to have a collection of people there (for the same reason that vast amounts of other nearby locations never had a town at all, and just remained undeveloped land which, honestly, is perfectly fine).