Add a timeout by using the pcntl_alarm.  This will kill the process and log a message after 25 minutes.