Contrary to the fears expressed in antiquity, the Sun is not at risk of sudden extinction, and such a scenario is not compatible with the basic laws of physics that we know about.
We consider a hypothetical situation in which the Sun would somehow be deprived of energy and cease to emit light and heat. In this case, the Earth would not have cooled instantly, as it is possible to imagine, but would have experienced a longer cooling process.
If the Earth finds itself in orbit of an extinct and inanimate star, then the temperature will begin to decrease: within a week it will drop to -17 degrees Celsius, and in a year it will reach -73 degrees. The lack of photosynthesis will lead to the rapid decline of plant life, and as the oceans freeze, other forms of life will also stop their activity.
The protective top layers of ice would be able to keep deep waters from freezing for hundreds of thousands of years, creating conditions for the survival of some oceanic and geothermal life forms. Slow metabolism and sugar reserves will allow trees to remain viable for several decades. The best places for human existence will be nuclear submarines or living quarters built on the ocean floor and in regions rich in geothermal energy, such as Iceland.
Apart from low temperatures, life in the absence of the Sun could have some advantages. Solar flares would cease to pose a threat, which would improve satellite communications and conditions for astronomical observations.
However, in general, the presence of the Sun is an important factor in sustaining life on Earth.
If the Sun were to disappear (not go out, but disappear) for a second,
the absence of solar gravity would cause disturbances in the orbital motions of all objects in the solar system. By the time the Sun returns, the planets, including the gas giants and cosmic dust, would have moved into new orbits, some of which could be unstable. Also, for a brief moment, the heliosphere, which protects the solar system from external radiation, would disappear. This could trigger an intrusion of harmful radiation from outer space, causing auroras around the world, disrupting satellites and electrical wiring, and possibly sterilizing the Earth.
We live in a happy time!