Sariputta and Maha Cunda visit Channa who is dying a painful death. Channa announces he will 'take the knife' (commit suicide). Sariputta questions him as to his understanding of Dhamma and Maha Cunda recites for him a saying of the Buddha warning against the wavering that results from attachments. Later, after Channa has 'taken the knife' Sariputta questions the Buddha as to Channa's fate. The Buddha states that his was a blameless end.
Read the Sutta
Index of Available translations: SN 4.35.87
The question of suicide comes up periodically and is worth examining carefully.
This is an outline of the factors involved:
'Blameability' here means incurring a bad kammic outcome. This result rests on the idea that a. 'this' is not the self and consequently b. killing 'this' is ranked with murder.
This is the outcome for anyone who, killing this body, ends up taking up rebirth in another body.
This means that a blameable outcome is to be expected for anyone who commits suicide who is at that time less advanced than the non-returner who is able to attain arahantship at death.
Arahants do not commit suicide as they do not experience pain in a way which interfears with their mental stability (which is the excuse that justifies suicide for the person who does not incur blame for suicide.)
The suttas do not go into the outcome for the lesser cases of suicide, but one can extrapolate from related situations that the degree of bad outcome is modified to the extent of an individual's ability to comprehend the situation in terms of the Dhamma, and his ability to let go of attachments, at the point of or shortly after death but before taking up a new birth.
In this sutta both Sariputta and Maha Cunda doubt Channa's understanding, both apparently basing their doubt on Channa's fondness for the company of laymen. The Buddha explains that although such attachment is a dangerous thing, it is the taking of one's own life for the sake of taking up rebirth in another body that is the issue in the case of suicide. Channa was above this error and knew he was above such an error.
For an alternative translation see Ms. Horner's translation of MN 144, which is identical to this.
anissitassa calitaṃ n'atthi,||
calite asati passaddhi hoti,||
passaddhiyā sati nati na hoti,||
natiyā asati āgatigati na hoti,||
āgatigatiyā asati cutupapāto na hoti,||
cut'upapāte asati nevidha na huraṃ||
na ubhayam antarena||
esevanto dukkhassā.|| ||
In him that clingeth, there is wavering,
In him that clingeth not, wavering is not,
Where is no wavering, there is calm,
Where is calm, there is no bent,
Where is no bent, there is no wrong practice,
Where is no wrong practice, there is no vanishing and reappearing,
If there be no vanishing and reappearing, there is no here
nor yet midway.
That is the end of ill.
SN 4.35.87, Woodward translating a saying of the Buddha uttered by Mahā Cundo.
'For him who clings there is wavering;
for him who clings not there is no wavering;
if there is no wavering there is impassibility;
if there is impassibility there is no yearning;
if there is no yearning, there is no coming and going;
if there is no coming and going, there is no deceasing and uprising;
if there is no deceasing and uprising,
there is no "here" itself
nor "in between the two."
This is itself the end of anguish.'
Ms. Horner's translation from MN 144