I got what would happen to it after the natural death of the owner (power of the wand breaks) but will the same happen if the owner commits suicide?
Ownership of the Elder Wand is based on defeating its former owner, in whatever way one can. It can be through magical duel, outright assassination or simple tug-o-war, as seen when Harry grabs the Elder Wand out of Draco Malfoy's hand.
Thus, if the owner of the wand would commit suicide without having been defeated since becoming the owner, then the power of the wand would also break, as there would be no one to take ownership of it since the current owner was not defeated by anyone.
It is explained by Harry Potter to Voldemort quite clearly in Chapter 36 of The Deathly Hallows:
“Aren’t you listening? Snape never beat Dumbledore! Dumbledore’s death was planned between them! Dumbledore intended to die undefeated, the wand’s last true master! If all had gone as planned, the wand’s power would have died with him, because it had never been won from him!”
Basically, Dumbledore planned his suicide with the assistance of Severus Snape. If it had worked as planned, then the power of the Elder Wand would have been broken.
The power of the Elder Wand is broken if the owner dies a natural death without having been defeated.
I’m putting the Elder Wand,” he told Dumbledore, who was watching him with enormous affection and admiration, “back where it came from. It can stay there. If I die a natural death like Ignotus, its power will be broken, won’t it? The previous master will never have been defeated. That’ll be the end of it.”
Dumbledore nodded. They smiled at each other.
Harry Potter and the Deathly Hallows, Chapter 36, "The Flaw in the Plan"
Considering the owner would be dead if they committed suicide whether or not that counts as defeating themselves doesn't matter. It would appear as the Elder Wand would then have no master as the master would be dead and so most likely the power would be broken.
If the suicide has a reason behind it, such as another person causing the victim despair, I think it might be possible for the wand to recognize this emotional defeat and bow to person who caused emotional distress.