In a nutshell, what happens to the real property after the rail line is formally abandoned (or service is permanently discontinued in the case of a line that doesn’t need to be formally announced) depends on the language of the deed into the railroad and how the courts in the state where the line is located interpret that language.
For example, if a railroad is granted property in MI for a “ railroad, and for no other purpose”, MI courts have held that that language grants the railroad ownership rather than something like an easement. The deed must include express language creating a reversionary right if the railroad ever ceases to exist before an abutting land owner can lay claim to the property.