Do you need to stay until the end of the match to receive all of the research points?

I sometimes die quite quickly when playing as bomber.
Is it better to spectate until the end of match or start a new match?

Start a new match.

Surviving longer is what gives greater rewards, but dying and staying in the match doesn’t increase them.

Biggest contributor to RP gain is playtime (that is then multiplied by activity percentage which is a metric based of match score and time). Staying and spectating after getting destroyed will not effect your RP or SL in any way.

Sometimes you can get a bit more “Time Played” if you ride the plane all the way to the ground and you are then officially recorded as “destroyed”.

Keep in mind the RP loss bug. If you have some mod being researched and you jump into another match, you will lose the difference in RP between what finished it and your total score. So it behooves you to wait, maybe play a different nation until that game ends before using the same vehicle.

That should no longer be a thing unless it has re-emerged again after it got a fix a couple of months back.