Rails and scrap metal in general, and nearly always in the quantities that are discussed here, are usually recycled if the market is right for that. That is, “torn up” rails will be recycled, since the labor to recover them is the expensive part of the effort. After that labor is expended, it would be foolish not to collect them and sell them as scrap metal, since they do have value. (But that value is usually not enough to pay for the effort to pull them up, at least in Western economies. The scrap metal vs. labor valuations may be different in other parts of the world.) Some railways are simply abandoned as being uneconomic for rail traffic, and not worth the labor to tear up and sell the rails.
Ties will generally only be recovered when the whole rail line is being turned over, such as in New England where there are a lot of “rails to trails” bike trails. You can’t very will bicycle over railroad ties, so they have to be dug up. Those don’t have a lot of economic value, except there will always be uses for timbers of that size in good condition. They often go to make landscaping steps, berms, retaining walls, etc. in parks and in other places, including shoring up eroding parts of the same or other trails.