It’s not just about whether they have flaws or not, or whether they’re a Mary Sue. What’s important is to consider whether this character has their own arc. You say it’s this character’s time to die – so why is that? What purpose does their death serve, beyond advancing the plot? Do they have a complete story arc? Or if their arc is not completed, why is this tragic beyond the loss the character who is left behind experiences when they die? If you can answer those questions, you should be fine.
This is a very careful line to walk on. I love to kill characters off, so I need to take a look at their deaths and make sure they’re satisfying for the readers. There’s a death that I’ve been putting off writing. I really want to do it right.