What matters is your greater intent. If your intent is to commit suicide, presuming you are not mentally ill, you are guilty of a sin. However, if you die as a consequence of pursuing a greater good you have not sinned.
Peace be with you
and God knows your intent, right/ In fact, He knew you were going to commit suicide, before you were even conceived, didn’t He?