A group of communist leaders, unhappy with Gorbachev's idea, tried to take over Moscow and stop the Soviet Union from collapsing. It only made people want independence more. Although he survived the attempted takeover, he lost all of his power outside of Moscow. Russia declared independence in December 1991. Later in the month, leaders of Russia, Byelorussia, and Ukraine signed a treaty called the Belavezha Agreement to dissolve the USSR, extremely angering Gorbachev. He had no choice but to accept the treaty and resigned on Christmas Day 1991. The Soviet Union's parliament (Supreme Soviet) made the Belavezha Agreement law, marking formally the dissolution of the Soviet Union. The next day, the Soviet flag was lowered from the Kremlin for the last time.