fix: Check that webContents has not been destroyed (#215)
fix: Check that webContents has not been destroyed (#215)

* check that webContents have not been destroyed

When sending the  message to the renderers we have to make sure that they are ready to receive it by ensuring that the `WebContents` has not been destroyed. Otherwise Electron will crash with `TypeError: Object has been destroyed`.

An easy way to reproduce it is to create a browser window, log something on its `destroyed` event and then close the window:

```js
bw.webContents.on('destroyed', () => {
  logger.info('this will crash Electron when the window is closed');
});
```

* lint

* lint (again)

* Cosmetics

Co-authored-by: Alexey Prokhorov <ab9ee02e91e0f20496dfce95a06b59081ba20a0d@l96.ru>
megahertz/electron-log,megahertz/electron-log,megahertz/electron-log