How does the square end?
Google Sheets, 52 51 47 bytes
=ArrayFormula(Join(&quot;,&quot;,Unique(Mod(Row(A:A)^2,A1

Saved 4 bytes thanks to Taylor Scott
Sheets will automatically add 4 closing parentheses to the end of the formula.
It doesn't return the results in ascending order but it does return the correct results.