Multiple-engine configurations use multiple freewheeling units that couple the rotor with the engine and allow the first to revolve faster than the latter but not the other way around. If just one of the engines fails, the freewheeling unit for that particular engine will effectively disengage the engine from the rotor (as the rotor is now revolving faster than the failing engine), allowing the other engine(s) to drive it.
How a freewheeling unit functions on a mechanical level is described on page 6 of this document.