In general, wishing death upon oneself could have a positive or a negative motive.
A positive motive would be wanting to be closer to God, and recognizing this world, as not being worthy except for preparing for the meeting with the Lord. An example of this type is what god in the holy Quran tells those who claim to be close to God to wish for death.
The negative one which is forbidden is when one is complaining about their circumstances in other words, not pleased with God’s decree