That's also something I make sure of. If an exploratory up-down stack reveals a cavern, I immediately ensure that any cavern-side parts of the stack¹ is dedesignated and the uppermost up/down just below the cavern floor is redesignated as down-only ready for a diversion staircase² to feed back into without inadvertently opening access. The up/down that discovers the cavern (or the one above, if the the one that did was in an upper edge-wall) is then built upon by a constructed Up-stair to seal the entry-from-down.
The inevitable revelation of multiple gems/ores being discovered indicates where a new (planned!) view into the caverns has been dug that gives additional sight-lines beyond the edge of the original "New Cavern!" discovery, those typically being (re)defined as an up-down into a suitably visible safe bit of roof (which I'll be ready to consfruct an Up over almost immediately), the mid-void-area designations being ommitted/removed and the below-cavern-floor being (re)designated as down-only digging.
Depending on cavern openness and general luck of the draw, this technique might be searching for the nearest on-plan spot where a stairwell can lead down within closed rock (or, sometimes, down the middle of a suitably positioned 3x3 rock pillar) to reach the gap beneath this cavern and above the next, to link up with the continuation of explore-stairways grid. Or it might just be letting me further shape my nascent lateral plan around the wider grid, while hoping to see things of interest³.
In the time between the breaching of the cavern(/magma sea) and the construction of the up-stair I keep a very close eye on any potential invader. If there's no obviously routing-inwards FB or other pest I might actually take time to make sure I have a block of whatever native material the up/down is, as an only-I-will-ever-really-know aesthetic choice for building material of the up-stair that will cover it up. If I need to plug it quickly-ish but I've yet to fashion blocks in (say) the gabbro that I've only just encountered in this area, I often first build with spare cobaltite or other notably distinct rock so that I see it's 'wrong' and deconstruct it to reconstruct again with the right block-material when I have it (and there's time enough to do so). But that's just my particular finessing, not necessary.
For the OP's problem, this is probably well beyond what they need to do now. Except that "You have discovered a cavern" message-zoompoints could indicate the access you haven't stopped up, but also a bunch of discovered gems (in one sequence) might show you where a secondary cavern-access managed to see to, beyond the limits of the first, and you can search around and try to work out what other stop-upable breaches you have that you need to stop-up. Or what to try to do next time/the time after to avoid the same fate. (The above being sometimes hard-won knowledge for me, maybe it's not so obtusely written that it'll ease your own gradual understanding.)
¹ If I've intersected the cavern wall right on the edge, or even if I've hit a middle-of-ceiling space but the vertical column hits an in-cavern verticality in the lower visible void. Neither of which is any good for me.
² I tend to have multiple stairwells exploring down, part of my Grand Cross Section Plan, and one of them (or part of one of them, if it's greater than 1x1 in its fully-realised sense) will get past a cavern level, and connect back up with the stairwells that have to be abortively shut off.
³ Handy bodies of water I might tap into, magma tubes or (for when the 'cavern' concerned is the magma sea) suitable places to try to dig a floodgatable magmaduct feature out sideways and below where my magmaworkshops will be (assuming I haven't already managed this out of the side of a magmatube riser I obviously haven't already found).