It's not a perfect solution but something that I do, is anything that requires my full attention and prevents me from thinking about them.
I too am currently having this problem because I can get easily attached to fictional characters. I've been playing Honkai Impact 3rd, which is my first time playing a Mihoyoverse game, and the story (at least part 1, I'm not in part 1.5 or 2 yet) is so tragic, that I've developed an attachment to the characters. I've been trying to take breaks from playing, so I can focus on other things, but I get depressed if I go too long without playing it.