He did it in March not July, and before the Democrat primary.
LBJ dropped out of the race after the New Hampshire primary when Eugene McCarthy grabbed a third of the vote against him.