I have 2 view controllers A and B. The view controller A present view controller B by segue show. ViewController B has also a button which dismiss B and show A. There is no problem until here. 
After some functions completed in B, view controller B present a popup view and this popup include restart game and close game buttons. When press close game button, View Controller B and popup view should be dismissed and show main A view controller. How to accomplish this? Thank you
Here how to present popup view:
let popupVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "popupID") as! PopupViewController
        self.addChildViewController(popupVC)
        popupVC.view.frame = self.view.frame
        self.view.addSubview(popupVC.view)
        popupVC.didMove(toParentViewController: self)
 
     
    