Formation of topological defects in thin superconducting rings