The TVTropes Trope Finder is where you can come to ask questions like "Do we have this one?" and "What's the trope about...?" Trying to rediscover a long lost show or other medium but need a little help? Head to Media Finder and try your luck there. Want to propose a new trope? You should be over at You Know, That Thing Where.
I have seen these cases filed off under the umbrella trope Driven to Suicide. There is also Self-Punishment Over Failure which notes suicide in rare cases.
Edited by eroockFor versions that don't involve suicide: Bad Guys Do the Dirty Work?
Could also be Deus ex Machina if the cause of the problem-solving death isn't foreshadowed enough.
I'm not sure I completely understand the question or example, but I wanted to point out Self-Disposing Villain, which could include a villain killing himself (accidentally or on purpose) in a way that neatly avoids any moral quandary on the part of a Thou Shalt Not Kill type of protagonist.
A trope (mostly in older works, given the change social values) where people acknowledge someone dying (or outright killing themselves) is the best solution all around (usually involving avoiding a scandal or ruining other people's lives). Not Leave Behind a Pistol, where the victim is told that their suicide would arrange quite a few matters, this is the person dying or killing themselves without any outside suggestion.
For instance, one Hercule Poirot story sees the exposed murderer take a gun in full view of the rest of the cast after The Summation and declare he's going to hunt rabbits. Poirot himself stops them from going after the murderer, actually calling it the best solution as it avoids revealing the murderer had not only killed his wife, but was attempting to gaslight his (not actually his but his best friend's) son into suicide.