Tank is immobilized, crew -stays- in the vehicle unless it becomes unable to defend itself (turret immobilized, gun destroyed, on fire).
If damage to track/engine results in immobilized vehicle, crew checks for nearby threats.
If friendly vehicles/troops in own squad are nearby, one will bail out to perform the repair job. If he is killed, second one will bail out. Ditto for the last one. Simple behaviour.
No friendlies nearby, stay in the tank until nearby enemies are defeated, then leave it to repair.
Once repaired, board vehicle again, proceed with mission.