It's 1953's western film Shane.
Confirmed on thrillist.com too
And the full dialogue was:
Shane: I gotta be going one.
Joey: Why, Shane?
Shane: A man has to be what he is, Joey. Can't break the mould. I tried it and it didn't work for me.
Joey: We want you, Shane.
Shane: Joey, there's no living with... with a killing. There's no going back from one. Right or wrong, it's a brand. A brand sticks. There's no going back. Now you run on home to your mother, and tell her... tell her everything's all right. And there aren't any guns in the valley.
And here is video for that specific scene:
Mangold mentioned the 1953 Western Shane, the story of a tired gunfighter (Alan Ladd) who falls in with a boy and his family. That movie would influence the core relationship between Logan and Laura, who are both distrustful of the other but find common ground.
And if it was Jackman’s goodbye to Logan, Mangold thought it should definitely explore the hero’s biggest fear: “Is he frightened of villains? No. Aliens? No. Galactic destruction? No. His own demise? No. But he is scared of love.”
Even Mangold has a personal liking for the film, which is clear from his old tweet.