You can’t, not without complicated workarounds. Haproxy is not aware of your application status.
There is a similar thread on the mailing list, maybe you can get some input from there:
https://www.mail-archive.com/haproxy@formilux.org/msg26600.html
Maxconn limits the amount of concurrent requests. The amount of not-expired “application” sessions on your backend is unknown.