Stellar encounters as the origin of distant Solar System objects in highly eccentric orbits