flush buffer at program exit