<!--  As an open source project with a dedicated but small maintainer team, it can sometimes take a long time for issues to be addressed so please be patient and we will get back to you as soon as we can.
-->

### Preflight Checklist
<!-- Please ensure you've completed the following steps by replacing [ ] with [x]-->

* [x] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/master/CONTRIBUTING.md) for this project.
* [x] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/master/CODE_OF_CONDUCT.md) that this project adheres to.
* [x] I have searched the issue tracker for an issue that matches the one I want to file, without success.

### Issue Details

* **Electron Version:**
  * <!-- (output of `node_modules/.bin/electron --version`) e.g. 4.0.3 --> 7.0.0, 6.1.2, 5.0.11
* **Operating System:**
  * <!-- (Platform and Version) e.g. macOS 10.13.6 / Windows 10 (1803) / Ubuntu 18.04 x64 --> macOS 10.15
* **Last Known Working Electron version:**
  * <!-- (if applicable) e.g. 3.1.0 --> unknown

### Expected Behavior
<!-- A clear and concise description of what you expected to happen. -->
When using the Menu.popup API, Electron should not crash in AtomMenuController.menuDidClose.

### Actual Behavior
<!-- A clear and concise description of what actually happened. -->
When using the Menu.popup API, Electron will sometimes crash in AtomMenuController.menuDidClose.

### To Reproduce
<!--
Your best chance of getting this bug looked at quickly is to provide an example.
-->
Add this to main.js after creating mainWindow:
```javascript
  mainWindow.webContents.on('context-menu', () => {
    Menu.buildFromTemplate([{role: 'paste'}]).popup(mainWindow);
  });
```
Here is a gist with that change: https://gist.github.com/jeremyspiegel/53afd0127ec3fc3e1cad5bbef0e4c390

Then keep right-clicking to invoke the menu repeatedly until you see a crash.

You can make the crash happen reliably on the first time invoking the menu by forcing garbage collection — add `setTimeout(() => global.gc(), 0);` after running `Menu.popup`, and run Electron with `--js-flags="--expose-gc"` on the command line.

<!--
For bugs that can be encapsulated in a small experiment, you can use Electron Fiddle (https://github.com/electron/fiddle) to publish your example to a GitHub Gist and link it your bug report.
-->

<!--
If Fiddle is insufficient to produce an example, please provide an example REPOSITORY that can be cloned and run. You can fork electron-quick-start (https://github.com/electron/electron-quick-start) and include a link to the branch with your changes.
-->

<!--
If you provide a URL, please list the commands required to clone/setup/run your repo e.g.
```sh
$ git clone $YOUR_URL -b $BRANCH
$ npm install
$ npm start || electron .
```
-->

### Additional Information
<!-- Add any other context about the problem here. -->
@MarshallOfSound added a speculative fix in https://github.com/electron/electron/pull/20111 but it doesn't fix the issue.

The problem isn't that `model_` is null, but rather it appears to be that the `MenuMac` API object is destroyed while `MenuMac::PopupOnUI` is running (inside the `[menu popUpMenuPositioningItem:item atLocation:position inView:view]` call).

I added the following to the top of `MenuMac::PopupOnUI` to try to make it so that the object could not be garbage collected while in that function:
```c++
v8::HandleScope handle_scope(isolate());
GetWrapper();
```
That seemed to make the problem go away.
shell/browser/ui/cocoa/atom_menu_controller.h
#ifndef SHELL_BROWSER_UI_COCOA_ATOM_MENU_CONTROLLER_H_
#define SHELL_BROWSER_UI_COCOA_ATOM_MENU_CONTROLLER_H_
#import <Cocoa/Cocoa.h>
#include "base/callback.h"
#include "base/mac/scoped_nsobject.h"
#include "base/strings/string16.h"
namespace electron {
class AtomMenuModel;