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, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Whoever has not prayed Maghrib until the call to establish the prayer for 'Ishaa' is called, can do one of the following.
a) Join the (‘Ishaa’) congregation with the intention of Maghrib. When the third Rak’ah (unit) is finished, he can make the Tashah’hud (the prayer said while seated) and then say the Tasleem (i.e., saying ‘As-salaamu ‘Alaykum’ at the end) to end the prayer, then he can stand up to join the last Rak'ah with the Imaam, or he can remain sitting after the Tashah’hud until the Imaam finishes the prayer and say the Salaam at the same time with the Imaam.
b) Pray the 'Ishaa' prayer with the Imaam, then make up the Maghrib prayer after that without praying the 'Ishaa' prayer again.
Whichever of the above two possibilities he chooses to do, it would correct according to the opinions of the scholars.
Finally, we would like to draw the attention of the questioner to the issue of if the traveler prays behind a local person, he has to perform the prayer fully - regardless of whether he joins the prayer at the beginning or misses one or a few Rak'ahs, so if you missed one Rak'ah, you should have stood up to complete three other Rak'ahs for your 'Ishaa' prayer. Ibn Qudaamah said, “The conclusion is that if the traveler prays behind a local Imaam, he has to perform the prayer completely, regardless of whether he joined the prayer at the beginning, or he made one Rak'ah or less.”
Allaah Knows best.