Adding option to have errors sent on shutdown.

Usually I close the client connection and flush the output buffers before doing time consuming tasks that the client browser doesn't need to wait for. So having an option to wait until shutdown functions are called to send any errors is needed.