Read this and answer the question

The dissolution of the Soviet Union was formally enacted on December 26, 1991, as a result of the declaration no. 142-Н of the Soviet of the Republics of the Supreme Soviet of the Soviet Union. The declaration acknowledged the independence of the former Soviet republics and created the Commonwealth of Independent States (CIS), although five of the signatories ratified it much later or not at all. On the previous day, Soviet President Mikhail Gorbachev, the eighth and last leader of the Soviet Union, resigned, declared his office extinct, and handed over its powers – including control of the Soviet nuclear missile launching codes – to Russian President Boris Yeltsin. That evening at 7:32 p.m., the Soviet flag was lowered from the Kremlin for the last time and replaced with the pre-revolutionary Russian flag.

Who was president of the Soviet Union when it came to an end?
Mikhail Gorbachev,