now flushes before closing