@Ken Toh’s comment was what worked for me in this situation — call dismiss from the view controller that you want to show after everything else is dismissed.
If you have a “stack” of 3 presented view controllers A, B and C, where C is on top, then calling A.dismiss(animated: true, completion: nil) will dismiss B and C simultaneously.
If you don’t have a reference to the root of the stack, you could chain a couple of accesses to presentingViewController to get to it. Something like this:
self.presentingViewController?.presentingViewController?.dismiss(animated: true, completion: nil)