The survival instinct is not the only drive that decides whether or not a person will choose to continue or end his/her life. Other instincts that have been evolved to increase the survival chance of a clan/species, such as the instinct to procreate and to perpetuate his/her clan/species and the instinct to avoid pain/sufferings (both physical and mental), also have the effect.
That is why a mother/father can sacrifice her/his life for her/his child. That is why a person can sacrifice his/her life for his/her clan (nation) or humanity (his/her species). In some animals, it is even more obvious when the hive instinct is stronger than the individual instinct to survive – a bee or an ant will fight to its death to protect its colony.
When a person suffers a severe pain or other sufferings that he/she considers not curable, such as terminal cancer pain, the drive to avoid further sufferings can be stronger than the survival instinct. This is also the case for mental sufferings. If a person contemplates that he/she will have to endure shame, insult, humiliation, etc. that is unbearable for him/her, the drive to avoid sufferings can be stronger than the survival instinct too.
One may ask, then, why do we evolve the instinct to avoid pain/sufferings if it can lead us to premature death? The answer is that the instinct to avoid pain/sufferings in general cases help increase the survival chance of a species. Pain/sufferings, in general, are the early warnings of more serious danger or situations that may endanger life and therefore have to be avoided. The cases exampled in the previous paragraph are exceptional cases. The suicidal rate in people worldwide is only about 16/100,000 per year or about 0.016 percent per year among 7.7 billion people. It is just that evolution works in general cases, not in every particular case.
Befrienders Worldwide. Suicide Statistics
Eric R. Pianka. Can Human Instincts Be Controlled?
Ukahoke C.The Basic Theory of the Mind. Chapter 11 - Self