title: Stopping an active Testcafe run
body: <p>I try to add a stop function to the Testcafe run. I start Testcafe with:</p>
  
  <pre><code>let testcafe = null;
  let testcafeprom = null;
  
      testcafeprom = createTestCafe('localhost', 1337, 1338)
          .then(tc =&gt; {
              testcafe     = tc;
              const runner = testcafe.createRunner();
              return runner
                  .src([__basedir + '/tests/temp.js'])
                  .browsers(myBrowser)
                  //.browsers('browserstack:Chrome')
                  .screenshots(__basedir +'/allure/screenshots/', true)
                  .reporter(['uistatusreporter', {name: 'allure',output: 'test/report.json'}])
                  .run();
          })
          .then(failedCount =&gt; {
              testcafe.close();
              startReportGenerator();
              capcon.stopCapture(process.stdout);
              console.log("Testcafe Ende");
  
  
              if(failedCount&gt;0){
                  res.sendStatus(400);
                  console.log('Tests failed: ' + failedCount);
                  //res.statusCode = 400; //BadRequest 400
                  /*
                  res.json({
                      success: 'failed',
                      fails: failedCount
                  });
                  */
              }else{
                  //res.statusCode = 200; //BadRequest 400
                  res.sendStatus(200);
                  console.log('All success');
                  /*
                  res.json({
                      success: 'ok',
                      fails: failedCount
                  });
                  */
              }
          })
          .catch(error =&gt; {
              testcafe.close();
              console.log('Tests failed: Testcafe Error');
              console.log(error);
              res.sendStatus(401);
  
          });
  </code></pre>
  
  <p>Then I added a function to stop the run:</p>
  
  <pre><code>router.get('/stopit', async (req, res) =&gt; {
  
      testcafeprom.cancel();
      res.sendStatus(200);
  
  });
  </code></pre>
  
  <p>As I understand is that createTestCafe will return a promise and in all to stop the promise I call <code>testcafeprom.cancel();</code> or <code>testcafeprom.stop();</code></p>
  
  <p>But the browser is running and running. A simple <code>testcafe.close();</code> will stop Testcafe complete. But I want to stop it and not shoot it down.</p>
  
  <p>Any suggestion to stop it a better way?</p>
  
  <p>Update:
  I have also tested the way to make the runner as promise:</p>
  
  <pre><code>
      createTestCafe('localhost', 1337, 1338)
          .then(tc =&gt; {
              testcafe     = tc;
              const runner = testcafe.createRunner();
              testcafeprom =  runner
                  .src([__basedir + '/tests/temp.js'])
                  .browsers(myBrowser)
                  //.browsers('browserstack:Chrome')
                  .screenshots(__basedir +'/allure/screenshots/', true)
                  .reporter(['uistatusreporter', {name: 'allure',output: 'test/report.json'}])
                  .run();
  
              return testcafeprom;
  
          })
  </code></pre>
  
  <p>Adding also</p>
  
  <pre><code>await testcafeprom.cancel();
  </code></pre>
  
  <p>This will have exact the same result as <code>testCafe.close()</code>, means everything is shoot down without any response. Iam confused. </p>
  
  <p>And finally I tried:</p>
  
  <pre><code>let runner = null;
      createTestCafe('localhost', 1337, 1338, void 0, true)
          .then(testcafe =&gt; {
              runner = testcafe.createRunner();
          })
          .then(() =&gt; {
              return runner
                  .src([__basedir + '/tests/temp.js'])
                  .browsers(myBrowser)
                  //.browsers('browserstack:Chrome')
                  .screenshots(__basedir +'/allure/screenshots/', true)
                  .reporter(['uistatusreporter', {name: 'allure',output: 'test/report.json'}])
                  .run()
                  .then(failedCount =&gt; {
                      //testcafe.close();
                      startReportGenerator();
                      capcon.stopCapture(process.stdout);
                      console.log(`Finished. Count failed tests:${failedCount}`);
                      //process.exit(failedCount);
                      res.sendStatus(200);
                  });
          })
          .catch(error =&gt; {
              startReportGenerator();
              capcon.stopCapture(process.stdout);
              console.log(error);
              //process.exit(1);
              res.sendStatus(401);
          });
  </code></pre>
  
  <p>But here is the same. If I call await <code>runner.stop()</code> it looks like that the command will kill the whole process and nothing comes back to the promise.</p>
  
  <p>Is this such a secret how to stop a running TestCafe instance or is the secret that the whole process is shoot down?</p>