Use 0 for the index if the closest point is on the segment which closes the loop...