PHP using php_mod (standard Apache)
ob_start();
header("Connection: close\r\n");
header('Content-Encoding: none\r\n');
// your code here
$size = ob_get_length();
header("Content-Length: ". $size . "\r\n");
// send info immediately and close connection
ob_end_flush();
flush();
// run other process without the client attached.
For PHP using fastCGI and PHP_FPM :
// your code here
fastcgi_finish_request();
// run other process without the client attached.