firstly, infinite looping is really bad - if there is the slightest memory leak, you could bring down a web server fairly quickly, and so risk getting kicked off your hosting account. It's better to do a cron job to schedule a script to run instead.
If you still want to, have a look at [man]ignore_user_abort[/man]. Then you need to use [man]set_time_limit[/man] to set the time limit to 0 (no timeout).
adam