Said out loud, and recorded without rebuke

Maryam, in labour, says that she wishes she had died before this and had been forgotten entirely. Not a mild sentiment. The Qur'an records it, does not scold her for it, and then immediately provides for her.

If you have had a thought like that and concluded that it disqualifies you from something, the text is against you. It is in the Qur'an, said by one of the greatest women who ever lived, at the hardest moment of her life.

And now the part that must go with it, every time. This verse is not permission to leave that thought sitting where it is. If you have thought about ending your life, or worked out how you would do it, that is today. Tell someone in the room with you, and contact your doctor or an emergency service today. Both things are true at once. You are not disgraced, and it still needs help now.

Qur’an and Sunnah

فَأَجَآءَهَا ٱلۡمَخَاضُ إِلَىٰ جِذۡعِ ٱلنَّخۡلَةِ قَالَتۡ يَٰلَيۡتَنِي مِتُّ قَبۡلَ هَٰذَا وَكُنتُ نَسۡيࣰ ا مَّنسِيࣰّ ا

and, when the pains of childbirth drove her to [cling to] the trunk of a palm tree, she exclaimed, ‘I wish I had been dead and forgotten long before all this!’

Qur’an 19:23

Translation: M.A.S. Abdel Haleem, The Qur'an, Oxford University Press, 2004.