I would solve this task like this:

In a circle created with Geometry Nodes, there are no duplicate points, so the actual start point is not at the same position as the end point.
Instead, these are connected by declaring the curve as Cyclic.
In your example, however, the end point should be the same as the start point.
Therefore, you can simply create a circle that has one point less than your line, and using the math node Wrap you can use it to map the last queried point to the first when transferring the positions.
Update
Of course, you can also use other shapes with the same technique, such as a star:

The important thing is always: The number of points of your line is always one point larger than the number of points of the closed shape!

(Blender 3.2+)