Do proper wait for pending IO on clean exit