", $line, "\n"; } }); // Countdown RUN_TIME seconds then end the event loop $secondsRemaining = RUN_TIME; Amp\repeat(function() use (&$secondsRemaining) { if (--$secondsRemaining > 0) { echo "$secondsRemaining seconds to shutdown\n"; } else { Amp\stop(); // <-- explicitly stop the loop } }, $msInterval = 1000); });