In my TabBarViewController, I create a UINavigationController and present it as a modal.
TabBarViewController
var navController = UINavigationController() let messageVC
You can use the following to correctly dismiss a UINavigationController that's presented as a modal in Swift 4:
UINavigationController
self.navigationController?.popViewController(animated: true)