I was waiting to see if anyone else had done this trick. No chimers having chimed in, I take a guess....
I don't know if this will achieve the desired effect, but....... I would try separating the code into two chunks (one file with two parts). The first would be the chunk that would do all of the web response work. Then, it would launch the second chunk via an 'exec'. My hope would be that the web server would see the initial process close and thus the connection would close..... meanwhile... the child created by the 'exec' would go on it's merry way doing what ever you like. Like I said/wrote, I have not tried this, but, it is the first place I thought I would start playing.
I don't have time to try it today. I'll try to get back to it and if it works I'll post a little code. If you are new to Tek-Tips, please use descriptive titles, check the FAQs,
and beware the evil typo.