The activist that shook up CSX Corp. has wound down most of its investment in the railroad operator, marking an end to a three-year saga that helped spur a massive overhaul of the U.S. railroad industry.

Paul Hilal’s investment vehicle, Mantle Ridge LP, has sold off nearly all of its $1 billion position in CSX, according to securities filings. About 4.7 million shares were bought back by the railroad.

Mr....