Fix save_canvas: close stream immediately after write XML