Junk food's a great analogy. When encountering delicious junk food we're biologically compulsed to gorge. And just like we learn to moderate our junk food intake, it's easy enough to learn the warning signs of doom scrolling and put an end to it (just takes awareness and discipline).
Side note: I do the same when I (through force of habit) start a game of bullet chess, there's about 5 seconds before the game starts - just enough time to quickly cancel! (if I play 1 bullet chess game, I'll probably play 5 more right after, so quickly escaping when I shouldn't be playing is a huge benefit).
Use self-discipline to cultivate a state of mind like you would cultivate a healthy body.