       @driver.visit = @driver.get
 
   @After ->
-    terminateDriver() unless shouldPreventBrowserReload()
+    if @driver?
+      terminateDriver() unless shouldPreventBrowserReload()
 
   @registerHandler "AfterFeatures", (event, callback) =>
-    if shouldPreventBrowserReload()
-      terminateDriver().then -> callback()
+    if shouldPreventBrowserReload() and @driver?
+      terminateDriver().then callback
     else
       callback()
 

    .createFlow (flow) =>
      flow.execute =>
        code.apply(@, args)
    .then (result) -> 
      successCallback null, result
    , errCallback



module.exports = ->
  @Driver = Driver

  _Before = @Before
  _After  = @After

