Here's the one the developers use-
_grp = _this select 0
_vehicle = _this select 1
_aunits = units _grp
_i = 0
_j = count _aunits
#Here
(_aunits select _i) action ["EJECT",_vehicle]
unassignvehicle (_aunits select _i)
_i=_i+1
~0.5
?_j>_i:goto "Here"
"unassignvehicle _x" forEach units _grp
exit
To call the script, use groupname and heloname
[Alpha, helo1] exec "eject.sqs"