The good examples are Toronto, for instance, where Metrolinx is acquiring ownership of rail corridors up to Barrie, to Richmond Hill, to Stouffville, and so on. Those lines were really marginal in the freight business for major freight railroads like Canadian National or Canadian Pacific. There's really no economic reason to maintain such lines. However, it doesn't mean that you have to lose freight service, because if the line can be used and justified economically for its passenger handling capability, it may still be able to support freight, for example, at night on a limited basis and operated by the private sector short-line railway companies. This system works well in California, for example, where the rail line in San Diego is a public transit resource that is also used for freight service.
The River Line in New Jersey is similarly a light rail system operating between Camden and Trenton, New Jersey, that is also used by freight trains at off hours in a limited way. So it still provides some basic freight connectivity even though those lines are well below the threshold at which they would be considered viable by a major railroad.
So there are options here. They are being explored in the Ottawa area by Transport Pontiac-Renfrew, which is an initiative of Pontiac County in Quebec and Renfrew County in Ontario, to take over the rail line between Ottawa and Pembroke from Canadian National, which really has no further interest in it, in order to preserve it for both freight and passenger use.