When closing the connection, automatically flush all async ops.