Javascript's garbage collector destroys popup menus created by menu.popup from api Menu even when they are still active. It can lead to a crash when during destruction phase (when js object is already destroyed but c++ instance of class electron::api::Menu still lives) user makes any interaction with it, like changing focused element.
shell/browser/api/atom_api_menu.cc
#include "shell/browser/api/atom_api_menu.h"
#include "native_mate/constructor.h"
#include "native_mate/dictionary.h"
#include "native_mate/object_template_builder.h"
#include "shell/browser/native_window.h"
#include "shell/common/native_mate_converters/accelerator_converter.h"
#include "shell/common/native_mate_converters/callback.h"
#include "shell/common/native_mate_converters/image_converter.h"
#include "shell/common/native_mate_converters/string16_converter.h"
#include "shell/common/node_includes.h"
namespace electron {
namespace api {
Menu::Menu(v8::Isolate* isolate, v8::Local<v8::Object> wrapper)
    : model_(new AtomMenuModel(this)) {
  InitWith(isolate, wrapper);
  model_->AddObserver(this);
}
Menu::~Menu() {
  if (model_) {
    model_->RemoveObserver(this);
  }
}
void Menu::AfterInit(v8::Isolate* isolate) {