yeah, basically they tally the number of estimated friendly and enemy kills and weigh them against each other, factoring in morale, current health level, difficulty... and probably a few more. but at the end of the day, they can still choose to go out in a blaze of glory. if nothing else, it denies you the points for a kill, prevents them being captured alive and might even take a few of your guys with it.