Garretts patches to get the writer.close callback to fire