If we can make energy storage simple and cheap enough
If you're thinking of big Tesla Powerwall-style batteries, that just kicks the problem ahead by a few years or decades.The materials needed to make those batteries are finite. They will become "the new oil" in N years.
Energy storage is going to be a big part of any sane energy future, but it's going to have to make heavy usage of non-battery means: giant flywheels? Pumping water? I don't know.
But energy can be stored by pumping heated water to deep wells in the bedrock for example or you can use excess power to generate hydrogen and feed it back to the grid via fuel cells when needed. All of this is doable, but also slow to build and currently expensive.
This is not an argument against recycling batteries, by the way. Chemical batteries are a big part of the future, and we should recycle them. But let's not be glib about any of these choices.
The existential problem with oil is climate change, not finite resources.
One word serves to explain why what you imagine won’t happen in time: profit. More specifically: oil profits.
Clearly this line of logic is not working, seen in Ukraine. At some point there is a person with enough power who wants to fight just because they can. Essentially humanity is at mercy of random power-hungry sociopaths to not bomb the nuclear power plants.
Regarding survivability of humanity I have similar fear but my current hope is that while weapons will continue to be more attainable their relevance might diminish. Why fight your neighbor if you have everything you need? But warlords create a problem of their own because they seem to exist to attain superiority for its own sake.