fix the bug that header not write down and trigger the closed event.