Metastability of a gold nanoring: Density-functional calculations