here's a way to align it 100%:
trackgen outputs delta x, delta y, delta z and delta angle.
delta z is obvious (use the same z start for the first as z end for the last segment)
if delta angle is anything else than zero, adjust one arc by this amount to sum up to 360 degrees overall turn angle
adjust delta y: if you have any segment that is exactly perpendicular to start lane, simply change the length of this one by delta y; otherwise use another straight segment and change the length by 1/cos(angle)*deltaY (angle being the angle between start lane and this segment)
now, delta y should be zero and you can adjust delta x by the length of start lane segment
and you're done