diff --git a/lib/appium.js b/lib/appium.js index ce5ac9668d3..aa7af941484 100644 --- a/lib/appium.js +++ b/lib/appium.js @@ -665,7 +665,7 @@ Appium.prototype.stop = function(cb) { logger.info('Shutting down appium session...'); if (this.isSafariLauncherApp === true) { this.device.leaveWebView(function() { - if (this.device.udid === null) { + if (this.device.udid === null && this.device.instruments !== null) { this.device.instruments.shutdown(function() { this.cleanupSession(null, cb); }.bind(this));