With TLS passthrough, HAProxy cannot signal a connection close at the HTTP level.
The health check timing directly determines how long it takes HAProxy to detect that a Keycloak instance is shutting down and stop routing new connections to it.
With the health check settings from the configuration above (inter 5s fall 3), it takes up to 15 seconds (3 failures x 5-second interval) for HAProxy to mark a Keycloak instance as down.
During this period, Keycloak must remain running to serve in-flight requests.
Therefore, configure the --shutdown-delay to be at least as long as the detection time:
bin/kc.[sh|bat] start --proxy-protocol-enabled true --health-enabled true --metrics-enabled true --shutdown-delay=30s
For a detailed explanation of shutdown phases and how to tune the delay and timeout values, see the Graceful HTTP shutdown section in the Configuring a reverse proxy guide.