All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
If a person commences an optional prayer and then the obligatory prayers starts, he should continue in his prayer and should not break it, but he has to finish it as soon as possible for the Saying of Allaah (which means): {and do not invalidate your deeds.}[Quran 47:33].
If he fears that he may miss the virtues of performing the prayer in a congregation if he continues in his optional prayer, then he has to abandon it and join the congregational prayer since prayer in congregation is an obligation and an obligation is more important then an optional prayer.
Another opinion for the Muslim scholars states that one has to break his optional prayer whether he fears missing the obligatory prayer or not, for the general saying of the Prophet : "If the Iqaamah is called for the (congregational) prayer then no other prayer (is valid) except the obligatory prayer." [Muslim] But the correct opinion is that the narration prohibits starting an optional prayer, and it does not prohibit completing the prayer.
As for the way of aborting the optional prayer, it may be ended with Tasleem as usual, or by any action that invalidates the prayer, or by walking out of it, but concluding with Tasleem is not compulsory. The prayer is invalidated simply by the intention of aborting it.
Allaah Knows best.