What helps me to stay (or at least return to) on task is practice, practice, practice.

I see it as a form of habit building.
Also, and this took years and years plus I still work on it, I have to really know that I'm worth it. I deserve good things. It is okay for me to find some sense of balance.
Helps me to notice when my anxiety is growing and then tell myself soothing things. Including to keep it simple.
Sometimes helps to think of my mental health challenges as if they were physical. So being really anxious might be like having two broken legs, a cut on my shoulder, and whatever else, all needs time to heal. Physical stuff is visible and we can all go "Oh yeah, she needs to rest up. This isn't the time to take on any new battles.".
I wouldn't feel guilty or fuss about resting up with physical injuries. I try to apply this to what I need for emotional and mental stuff too.