A batter hits the ball and runs from the striker’s end to the non-strikers end, he then leaves his ground looking for a second run, stops and tries to return to the non-strikers end but is run out at the non-strikers end. Does the run count?
Yes. The completed run scores as if the batter had simply stopped running.
Law 18 defines what a run is, and whether they are scored when a dismissal occurs. The relevant parts of law are
18.1 A run
The score shall be reckoned by runs. A run is scored
18.1.1 so often as the batter, at any time while the ball is in play, have crossed and made good their ground from end to end.
18.8 Runs scored when a batter is dismissed
When a batter is dismissed, any runs for penalties awarded to either side shall stand. No other runs shall be credited to the batting side, except as follows.
18.8.2 If a batter is dismissed Run out, the batting side shall also score any runs completed before the wicket was put down.