Is there a way to safely end the driver instance without triggering an exception? At times, it seems to quit prematurely before completing any tasks.
driver.get('http://www.google.com');
var query = driver.wait(until.elementLocated(By.name("q")));
query.sendKeys('webdriver\n');
driver.wait(until.titleIs('webdriver - Google Search'));
driver.quit();