There is no shame in surrender when all options are exhausted. Only the savages with total disregard to human lives, such as the Japanese during WWII, would choose death over surrender en mass.
On the other hand, if you can certainly avoid capture if you avoid battle.