Ensure vg is closed when raising an exception