I had similar thoughts. Not so much just "species as a whole" (though it could be as well, and perhaps extend even further) but more so those close to you and your community which would likely, evolutionary/statistically speaking, share similar genes compared to "the competition". This is assuming the "suicide gene", or genetic make up, is at least in part positive and not a defect.
Not exactly the same, but risking or sacrificing one's life might be in part influenced by the same genes…or even making sacrifices such as adoption or other philanthropy.
This could be totally wrong and of course fortunately we don't need genetics as motives for all our actions. (though it may help if there is good alignment)