fix output before termination