In my actual app the UINavigationController is the rootViewController, and it crashes when the user kills the application (using swipe up gesture).
I tried a bunch of things, but the following code ended up fixing the issue for me.
class NavigationController: UINavigationController {
override func viewWillDisappear(_ animated: Bool) {
if !animated {
setViewControllers([], animated: false)
}
super.viewWillDisappear(animated)
}
}