Register a shutdown function to log fatal errors
Once a response has been sent, terminate the thread

Allows script processing to continue after the response has been sent to the client.