tweak to timing of final buffer flush in cleanup