How to close Chrome running in Kiosk mode programmatically?

Viewed 543

I have an Angular 9 app running in Chrome which itself is running in Kiosk mode. I need an option to close Chrome since there is no keyboard attached to the PC where the app is running.

Is there a way to do this programmatically without using an extenstion? A switch to another browser is possible.

I tried to get the window object in Angular and call window.close(); but it seems as if I didn't get the right one and only a component of the app closed instead of the chrome window.

I know that you can't close a window that wasn't opened with JavaScript but going off the comment on this answer I thought that Kiosk mode might be different.

Edit:

The component closing happened because of a bug in our own software and window.close(); doesn't work which is the expected behaviour.

1 Answers

You can write a watchdog process that will:

  • Launch the browser
  • Monitor the window title

If the window title changes to something like 'TERMINATING - Chrome', which is something you can change from within JavaScript, the watchdog process can kill the browser process.

The watchdog could also restart the browser if it crashes on its own without requesting termination.

Related