nginx-0.0.1-2004-01-16-09:15:48 import
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
index a6fb08a..f685bf3 100644
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -921,18 +921,21 @@
 
     clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
 
-    if (r->keepalive != 0 && clcf->keepalive_timeout > 0) {
+    if (!ngx_terminate
+         && !ngx_quit
+         && r->keepalive != 0
+         && clcf->keepalive_timeout > 0)
+    {
         ngx_http_set_keepalive(r);
+        return;
 
     } else if (r->lingering_close && clcf->lingering_timeout > 0) {
         ngx_http_set_lingering_close(r);
-
-    } else {
-        ngx_http_close_request(r, 0);
-        ngx_http_close_connection(r->connection);
+        return;
     }
 
-    return;
+    ngx_http_close_request(r, 0);
+    ngx_http_close_connection(r->connection);
 }