I believe this to be the motives behind most mass shootings. They know they are going to die.
It's about getting their name printed on newspapers, shown in the news, talked about for a few days before the cycle repeats.
We would be better served if the news simply referred to the shooter as "an assailant" and never say their names.
https://en.wikipedia.org/wiki/Cutting_off_one%27s_nose_to_spite_one%27s_face?wprov=sfla1
I've always heard it as "Cut off your own nose to spit in someone's face".
Basically it means you are willing to hurt yourself just to be able to make your enemy miserable.