diff --git a/atom/browser/api/atom_api_browser_window.cc b/atom/browser/api/atom_api_browser_window.cc index 5a429e9a1e31f..2e13df72971d0 100644 --- a/atom/browser/api/atom_api_browser_window.cc +++ b/atom/browser/api/atom_api_browser_window.cc @@ -94,11 +94,12 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate, } BrowserWindow::~BrowserWindow() { - api_web_contents_->RemoveObserver(this); // Note that the OnWindowClosed will not be called after the destructor runs, // since the window object is managed by the TopLevelWindow class. - if (web_contents()) + if (web_contents()) { + api_web_contents_->RemoveObserver(this); Cleanup(); + } } void BrowserWindow::OnInputEvent(const blink::WebInputEvent& event) {