I haven't seen this in any of the suttas. Unless you site relevant suttas, I will treat this as a total fabrication.
"Monks, these two extremes ought not to be practiced by one who has gone forth from the household life. (What are the two?)
There is addiction to indulgence of sense-pleasures, which is low, coarse, the way of ordinary people, unworthy, and unprofitable; and there is addiction to self-mortification, which is painful, unworthy, and unprofitable.
"Avoiding both these extremes, the Tathagata (The Perfect One) has realized the Middle Path; it gives vision, gives knowledge, and leads to calm, to insight, to enlightenment and to Nibbana. And what is that Middle Path realized by the Tathagata...? It is the Noble Eightfold path, and nothing else, namely: right understanding, right thought, right speech, right action, right livelihood, right effort, right mindfulness and right concentration. This is the Middle Path realized by the Tathagata which gives vision, which gives knowledge, and leads to calm, to insight, to enlightenment, and to Nibbana.
"The Noble Truth of Suffering
(dukkha), monks, is this: Birth is suffering, aging is suffering, sickness is suffering, death is suffering, association with the unpleasant is suffering, dissociation from the pleasant is suffering, not to receive what one desires is suffering — in brief the five aggregates subject to grasping are suffering.
"The Noble Truth of the Origin (cause) of Suffering is this: It is this craving (thirst) which produces re-becoming (rebirth) accompanied by passionate greed, and finding fresh delight now here, and now there, namely craving for sense pleasure, craving for existence and craving for non-existence (self-annihilation).
"The Noble Truth of the Cessation of Suffering is this: It is the complete cessation of that very craving, giving it up, relinquishing it, liberating oneself from it, and detaching oneself from it.
"The Noble Truth of the Path Leading to the Cessation of Suffering is this: It is the Noble Eightfold Path, and nothing else, namely: right understanding, right thought, right speech, right action, right livelihood, right effort, right mindfulness and right concentration.
-source-
Buddha taught the cessation of dukkha, which was accomplished via following the Noble Eightfold Path, not through suicide.
Ruining your body is called the extreme of self-mortification, and it is to be avoided as being unprofitable and unworthy.