Using events in renderer process throw error on development console
saying Attempting to call a function in a renderer window that has been closed or released.
win.on('maximize', toggleMaxRestoreButtons);
win.on('unmaximize', toggleMaxRestoreButtons);
This will cause error because you haven't cleaned up correctly and a listener exists on a remote object from a renderer that does not exist any more.
Solution - Avoid using remote or clean up your event handlers on remote objects if you have to use it
Add event remover in your code where you had added events code
window.onbeforeunload = (e) => {
win.removeAllListeners();
};
This will remove ALL listeners attached to your window before unloading it.
Note - onbeforeunload will be called before page is refreshed or closed.
Screenshot-

Conclusion- update tutorial to adapt to solution
To reproduce-
This is not same as your tutorial but here too I am using win.on events for blur and focus and it throws errors.
https://gist.github.com/AtiqGauri/1cea1c548025faa77f9f29008ca5a5fe#file-main-js-L4
Using events in renderer process throw error on development console
saying Attempting to call a function in a renderer window that has been closed or released.
This will cause error because you haven't cleaned up correctly and a listener exists on a remote object from a renderer that does not exist any more.
Solution - Avoid using remote or clean up your event handlers on remote objects if you have to use it
Add event remover in your code where you had added events code
This will remove ALL listeners attached to your window before unloading it.
Note - onbeforeunload will be called before page is refreshed or closed.
Screenshot-

Conclusion- update tutorial to adapt to solution
To reproduce-
This is not same as your tutorial but here too I am using win.on events for blur and focus and it throws errors.
https://gist.github.com/AtiqGauri/1cea1c548025faa77f9f29008ca5a5fe#file-main-js-L4