flush before closing