Fix closest point on last segment of polygon (fixes #4)