flush output in case of exception