It is recorded in an authentic hadeeth,
“If the congregational prayer starts, there is no other prayer.” (Muslim 710)
Based on this, if a person is praying voluntary prayers and the congregational prayer starts, the dictates of the hadeeth suggest one should stop the voluntary prayer. Therefore, one should end the prayer in the manner described and join the imaam. Relevant to this question is the statement of Allaah,
(وَلَا تُبۡطِلُوٓاْ أَعۡمَٰلَكُمۡ)
“… and do not invalidate your deeds…” (Muhammad 33)
Thus, if it is possible to complete the voluntary prayer by hastening it and then join the prayer, the person should do so. To elaborate, some scholars say that if you have finished one unit of prayer, you should hasten and complete the other unit, but if you have not completed one unit of prayer, you should break the prayer and join the congregation, so that you may not lose any units of the compulsory prayer. The evidence for this is
“If the congregational prayer starts, there is no other prayer.”
However, for a person who has completed one unit, he should then complete that prayer. This is because one complete unit is called prayer. In any case, the explanation given above is better.