Хотя нет... Немного перестроив принцип работы самого скрипта, подойдет.
Вроде бы разобрался. Работает. Если что то не так - подправьте, пожалуйста.
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <script>
    var eventSource;
    function start() { // 
   
      if (!window.EventSource) {
        alert('В этом браузере нет поддержки EventSource.');
        return;
      }
      eventSource = new EventSource('test.php');
      eventSource.onopen = function(e) {
        // соединение открыто
      };
      eventSource.onerror = function(e) {
        if (this.readyState == EventSource.CONNECTING) {
         
        } else {
          log("Ошибка, состояние: " + this.readyState);
        }
      };
      eventSource.addEventListener('bye', function(e) {
	    eventSource.close();
        log("Выполнение задания завершено");
		
      }, false);
      eventSource.onmessage = function(e) {
        console.log(e);
        log(e.data);
      };
    }
    function stop() {
      eventSource.close();
      log("Соединение завершено");
    }
	
    function log(msg) {
      logElem.innerHTML = msg + "<br>";
    }
  </script>
</head>
<body onload="start()">
 
  <div id="logElem"></div>
</body>
</html>
файл test.php
<?php
header ('Content-Type: text/event-stream; charset=utf-8');
$data = file_get_contents ( 'temp.txt' );
echo "data: " . $data . "%\r\n\r\n";
if ( $data == 100)
{
	echo "event: bye\r\n";
	echo "data: 100\r\n\r\n";
	file_put_contents ( 'temp.txt', 95 );
	exit;
}
file_put_contents ( 'temp.txt', $data + 1 );
?>