diff --git a/lib/devices/android/android.js b/lib/devices/android/android.js index 93b8fb522..784a25ad4 100644 --- a/lib/devices/android/android.js +++ b/lib/devices/android/android.js @@ -273,10 +273,15 @@ Android.prototype.cleanup = function() { Android.prototype.shutdown = function(cb) { var next = function() { - this.uiautomator.shutdown(function() { + if (this.uiautomator) { + this.uiautomator.shutdown(function() { + this.cleanup(); + cb(); + }.bind(this)); + } else { this.cleanup(); cb(); - }.bind(this)); + } }.bind(this); if (this.adb) {