Inhibiting failure spreading in complex networks