The game doesn't know it, but you do. You have to think of a way to link "completed quest" to "quest's index" (index as in the number it is saved under... for example Quest[2]; where the number 2 in bracket is the quest's index).
The only way that I can think of is that you yourself index each quest, giving it a unique number. That can be done by creating all quests at map initialization and disabling them, or in each separate trigger.
I will post an example one that fires at map ini:
-
Untitled Trigger 001
-

Events
-

Conditions
-

Actions
-


Quest - Create a Required, undiscovered quest titled Asdf with the description njhtrngs, using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
-


Set Quest[1] = (Last created quest)
-


Quest - Disable Quest[1]
-


-------- ---------------------------------------- --------
-


Quest - Create a Required, undiscovered quest titled TGd with the description oipodda, using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
-


Set Quest[2] = (Last created quest)
-


Quest - Disable Quest[2]
-


-------- ---------------------------------------- --------
-


-------- and so on... --------
Now with this, you specifically set which quest is saved as Quest[1], which as Quest[2].
The trigger, which ends quest is usually 1 trigger per quest, so you know exactly which trigger corresponds to which quest.
So if a trigger that ends quest fires, you know which quest it's supposed to end... like this:
-
Untitled Trigger 001
-

Events
-

Conditions
-

Actions
-


Trigger - Turn off (This trigger)
-


-------- I know that when the Boss dies, he fires this trigger and completes Quest[1] - that will not change, no matter what --------
-


-------- so I know which Quest shoul be marked as completed. --------
-


Quest - Mark Quest[1] as Completed
-


Quest - Display to (All players) the Quest Completed message: You did it! That gu...
Note, that the index number cannot be dynamic - in other words, that number has to be the same, no matter if that quest is accepted as first, second, or last.
Ex.
I have 6 quests in my map. I pick up the quest called "Flowers for Mary" as the last quest, however in triggers, that quest will have index for example 2 (= Quest[2]), because the mapmaker set it like that.