I definitely struggle with this, particularly when I'm obsessing over my blood sugar numbers or second-guessing my food choices.
A few things that help me: I've gotten into cooking low-carb recipes, which keeps my hands busy and my mind focused on something productive. I try hard at it even though I'm not that good. Also just going for walks around the neighborhood - clears my head and helps with blood sugar too. It's nice to find activities that help both mentally and physically.