First, you should never call header()
just like that, unless you are very sure that the Drupal helpers are not appropriate (I have never come across such a situation in my 10+ years of Drupal development)
header()
will not call the shutdown and other closing functions in Drupal, resulting in potentially broken sessions, wrong statistics and broken modules (which depend on closing being invoked). The fact that sockets and other low-level resources are not closed in such cases, might even crash your apache server (or other servers) at some point.
Rather call drupal_set_header() if you want to set a header. Nine out of ten times you want a redirection header, in wich case you best call drupal_goto(), wich does all the closing and even supports destination-paramters to be followed.
On drupal_goto, all processes are killed (see the exit()
at the bottom), hence no running process will be kept. The module_invoke_all('exit')
will make sure that all modules get a turn in closing their sockets, connections and what more.