Close boundaries by duplicating first point to last point if necessary