Triggering driver.close()

Is there a standard way to trigger driver.close() upon application exit?

Is there any way to provide a message upon successful completion of driver.close()?

Is this a node.js application or a webpage using the javascript driver?

driver.close();
alert('Driver successfully closed!');

would work to let you know it was successful, if driver.close() has an error then the alert line would not run (or use a console.log or some custom function)

Jacob,

Thanks for your guidance here.

This will be a front end webpage application using the javascript driver. Users will utilize the app periodically during their work day. I'm thinking I want to close the driver when the user closes the tab or browser. I suspect I'll need to trigger this driver close on the onbeforeunload event, but am asking if there is common standard recommendation for which event trigger to use to close the driver?

Also, if the driver.close() operates asynchronously, wouldn't the "Driver successfully closed" always be displayed even if the .close() function fails?

Thanks again,
Dennis

Not postive, but I think the driver.close() is synchronous.

If its not, then you would do driver.close().then(function() { alert('Driver sucessfully closed!'); });

I've got no guidance on a comment event to use, a lot of my front end development is with React.js so it works a little different.