diff --git a/lib/driver.js b/lib/driver.js
index <HASH>..<HASH> 100644
--- a/lib/driver.js
+++ b/lib/driver.js
@@ -481,6 +481,15 @@ class AndroidUiautomator2Driver extends BaseDriver {
         }
       }
       await this.adb.stopLogcat();
+      if (util.hasValue(this.opts.systemPort)) {
+        try {
+          await this.adb.removePortForward(this.opts.systemPort);
+        } catch (error) {
+          logger.warn(`Unable to remove port forward '${error.message}'`);
+          // Ignore, this block will also be called when we fall in catch block
+          // and before even port forward.
+        }
+      }
       if (this.opts.reboot) {
         let avdName = this.opts.avd.replace('@', '');
         logger.debug(`Closing emulator '${avdName}'`);
@@ -492,15 +501,6 @@ class AndroidUiautomator2Driver extends BaseDriver {
       }
     }
     await super.deleteSession();
-    if (this.opts.systemPort !== undefined && this.adb) {
-      try {
-        await this.adb.removePortForward(this.opts.systemPort);
-      } catch (error) {
-        logger.warn(`Unable to remove port forward '${error.message}'`);
-        //Ignore, this block will also be called when we fall in catch block
-        // and before even port forward.
-      }
-    }
   }
 
   async checkAppPresent () {
Remove port forward before killing emulator (#<I>)

* Remove port forward before killing emulator



* Use `util.hasValue()` to check if option is set



* trig ci