// forcibly flush before letting go of the resources to help older windows systems write correctly
Changed the exit process so that the final file write and closure is complete before the UI disappears instead of afterwards.