on domain error wait 3 seconds to send 500 to allow for other cleanup.
Also check inside function if the res has finished. #confused