This doesn't happen in the movie.
If we re-watch the scenes in question, we see that first of all Gollum falls into the Crack and pulls Frodo with him, then a number of things happen at the same time:
- Gollum dies
- The Ring is destroyed (which takes a few seconds longer)
- Sam pulls Frodo out
Then we cut over to Sauron being "destroyed", and - over an extended sequence - the Barad-dur falling, the Orc army scattering and the volcano erupting.
After this we cut back to Frodo and Sam escaping from the Crack of Doom, and it's obvious that this is taking place almost immediately after Sam pulled Frodo out; we can see the eruption beginning in the background of this scene too.
Later on, at the start the "End of all Things" scene, we get to see the early parts of the eruption after Frodo and Sam had gotten out.
It's particularly notable in this scene that the top part of the cone is still largely intact, whereas in the preceding scene it had already been mostly destroyed by the eruption (which is noticeably more violent too).
So what should be obvious is that we're not being shown a strictly linear sequence of events, but are instead jumping back a little in time to pick up the story of Frodo and Sam again, before the time at which the eruption occurs.