use finishRequest() (thanks @jerith)
dont write to a closed request (thanks @jerith)