diff --git a/lib/running.js b/lib/running.js
index <HASH>..<HASH> 100644
--- a/lib/running.js
+++ b/lib/running.js
@@ -171,7 +171,25 @@ exports.run = function(list, args, cb) {
   // finish so assume we can exit with the number of 'problems'
   if (typeof cb == 'undefined') {
     cb = function (problems) {
-      process.exit(problems);
+      // we only want to exit once we know everything has been written to stdout,
+      // otherwise sometimes not all the output from tests will have been written.
+      // So we write an empty string to stdout and then make sure it is done before
+      // exiting
+
+      var written = process.stdout.write('');
+      if (written) {
+        exit();
+      }
+      else {
+        process.stdout.on('drain', function drained() {
+          process.stdout.removeListener('drain', drained);
+          exit();
+        });
+      }
+
+      function exit() {
+        process.exit(problems);
+      }
     }
   }
   runner(list, options, cb);
Fix bug where sometimes console output would stop randomly with '%'