Liberation of quarks and spinons on domain walls: analogies between gauge theories and quantum magnets