Try this:
Create this script:
;closestcar.sqs
cars=[car1,car2,car3, etc] <<< create array of car names
_u=_this select 0
_dis=999999
_closestcar=car1
{_d=_u distance _x;if (_d<_dis) then {_dis=_d;_closestcar=_x}} foreach cars
_u domove getpos _closestcar
exit
call the script like this: [nameofsoldier] exec "closestcar.sqs"