A prime number wall pool table
By symmetry with respect to the mid-perpendicular of the side the motion is parallel to, the ball moves by an even number $2k$ of sides (which may be more than $\frac n2$, as in the case $n=3$) and the (polygonal or star) shape of the path is uniquely determined by the number $2k$, except that $n-2k$ and $2k$ generate the same. So if $n=2m$ is even, we have to check $k$ ranging from $1$ to $\lfloor \frac m2\rfloor =\lfloor \frac n4\rfloor$ inclusive, if $n$ is odd $k$ ranging from $1$ to $\frac{n-1}2$ inclusive. For each such $k$, one closed cycle involves every $d$th edge where $d=\gcd(n,2k)$, so we get $d$ distinct rotational copies of this path and the total number of closed cycles is $$\tag1 \sum_{k=1}^{\lfloor\frac n4\rfloor\text{ or }\frac{n-1}2}\gcd(n,2k).$$ It seems that this sequence $$ 0, 0, 1, 2, 2, 2, 3, 6, 6, 4, 5, 12, 6, 6, 15, 16, 8, 12, 9, 22, 22, 10, 11, 34, 20, 12, 27, 32, 14, 30$$ is not in OEIS (yet). By the way, if $n$ is an odd prime, then $(1)$ equals $\frac{n-1}{2}$.