Allow blocking connection process_events to still run while closing and add a functional test for it