title: dialog.showMessageBox not returning button index in electron main.js
body: <p>I have a messagebox that will open when the user click close on dashboardWindow (X button top right on windows os)</p>
  
  <pre><code>dashboardWindow.on("close", (event) =&gt; {
      event.preventDefault();
      console.log("before message box");
      dialog.showMessageBox(
        dashboardWindows,
        {
          message: "Test",
          buttons: ["Default Button", "Cancel Button"],
          defaultId: 0, // bound to buttons array
          cancelId: 1 // bound to buttons array
        },
        (response) =&gt; {
          if (response === 0) {
            // bound to buttons array
            console.log("Default button clicked.");
          } else if (response === 1) {
            // bound to buttons array
            console.log("Cancel button clicked.");
          }
        }
      );
      console.log("after message box");
    });
  }
  </code></pre>
  
  <p>The messagebox opened when i close the dashboardWindow but i can't get <code>response === 0</code> to work. Samehow <code>console.log("after message box");</code> already run even when there is no click on the buttons. How I can make the response work (return index button on messageBox)?</p>
  
  <p><a href="https://i.stack.imgur.com/9mIyq.png" rel="noreferrer">log on window close</a></p>