You have to run script through ajax, and button click regsiter session by ajax
foreach ($emails[0] as $m)
{
if (!isset($_SESSION['STOP'])) {
$m[] = $m;
}
else { //stop code here }
}