                 }
                 getApp().tabManager.selectTab(getApp().tabManager.tabs.first)
                 self.exitDeferred.fillIfUnfilled(())
+                ReentrantGuard.inFunc = false
             }
         }
     }


        isOn = false
        NSUserDefaults.standardUserDefaults().setBool(false, forKey: "WebKitPrivateBrowsingEnabled")

        NSNotificationCenter.defaultCenter().removeObserver(self)
        NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(allWebViewsKilled), name: kNotificationAllWebViewsDeallocated, object: nil)

        getApp().tabManager.removeAllPrivateTabsAndNotify(false)
        if BraveWebView.allocCounter < 1 {
            delay(0) {
                self.allWebViewsKilled()
            }
        }

        return exitDeferred
    }

    @objc func allWebViewsKilled() {
        NSNotificationCenter.defaultCenter().removeObserver(self)
        delay(0.25) { // even after all webviews killed, an added delay is needed before the webview state is fully cleared, this is horrible. Fortunately, I have only seen this behaviour on the simulator.


import Shared
import Deferred
import Crashlytics

private let _singleton = PrivateBrowsing()

