Here’s an interesting passage from Lama Yeshe’s book, “Life, Death, and After Death” in which he explains how to use distractions that arise during meditation as a way to develop a sense of closeness with others.
Lama Yeshe leads students in a meditation using the mantra OM AH HUM and then says:
If uncontrollable distracted thoughts arise, think that not only you but all sentient beings as well are in the same uncontrolled situation and generate equilibrium and much loving-kindness toward all others. In this way your uncontrolled mind becomes a resource for you to generate loving kindness. Contemplate on feeling loving-kindness for others. When loving-kindness arises, exert inattentive awareness on the mind of loving-kindness.
So there are two things you are doing in this meditation. Either you’re remaining in intensive awareness on your consciousness or, when distracted, exerting intensive awareness of the loving-kindness within your own mind. Alternate between these two.
So instead of getting frustrated when your mind starts running left, right, up and down, focus instead on how everyone struggles with their thoughts and emotions and that this is the nature of samsara. And this very realization opens the door for change.