diff --git a/mongoose.c b/mongoose.c
index 468aa276ebdbf45c2122d540cb04cd6cb6ef2ad6..b0139e1f4a3f2356eb21323864c6db3590ee196d 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -477,7 +477,7 @@ cry(struct mg_connection *conn, const char *fmt, ...)
 			(void) fprintf(fp, "%s", buf);
 			fputc('\n', fp);
 			funlockfile(fp);
-			/* (void) fclose(fp); */
+			if (fp != stderr) fclose(fp);
 		}
 	}
 	conn->request_info.log_message = NULL;