Context from core#19420:
This PR calls evhttp_free before releasing event base. But according to evhttp_free docs:
Works only if no requests are currently being served.
So this PR also tracks active requests with libevent and waits for last request to finish. This requires libevent 2.1 due to evhttp_request_set_on_complete_cb (https://github.com/libevent/libevent/blob/master/whatsnew-2.1.txt).
Finally, the call to evhttp_free is done in the event base loop to avoid concurrency issues.
Now test/functional/feature_abortnode.py quits normally, not due to socket timeouts.
This is a backport of core#26742 and core#28551
Depends on D17303