Here are some tips to make your PHP script work perfectly:
at beginning of your php file(s). This will let your script run until it finishes all jobs and doesn't care about users' stop button :)
Thanks Francesco for this tip :)
As most shared hosting disable functions set_time_limit and/or ignore_user_abort, you'd better don't output anything, or your output should be less than 4KB. Remember not to force your script to output (i.e using flush).
I tried it with shared hosting and my current server (LAMP), and my script which requires 150 seconds to complete works perfectly when set cron job at SetCronJob.