TOS: “What Are Little Girls Made Of?”
memory-alpha (dot) org/en/wiki/What_Are_Little_Girls_Made_Of%3F_(episode)
The science is sort of based off the events of Earth’s Cretaceous-Tertiary extinction event (the K-T event), though I’m not sure that underground caverns could have actually saved some of the population from dying. When something like that hits, it effects activity under the crust as much as it wreaks havoc on the atmosphere.