Committing suicide is a major sin in Islam because it comes as a result of losing hope in the mercy of Allah which is itself a major sin, and it is a crime of killing which is another major sin. Nevertheless, those who die during committing major sins, remain Muslims and we must perform on their dead bodies all rituals which must perform on any Muslim who dies e.g. Ghusl of the dead body, Kafan and burial in Muslim grave yard.
Allah (SWT) knows what is their hearts and He deals with them. We pray for all the believers to get the Mercy of Allah (SWT).