fix possible macrowriter exception while closing