What? Nobody wants the 'safer Quads'??
Many airlines, like Air Canada, Virgin Atlantic, LanChile, South African Airways, Cathay Pacific, Philippine Airlines, China Airlines, China Eastern, SriLankan, Lufthansa, SAS, etc, prefer A340 instead of B777 for long haul routes because A340 is of quad-engined design, so they are ETOPS-free, and hence can fly the most direct routing to save passengers' time. Not only this, A340 has much longer allowable diversion time (4.5 hours for non-LROPS compliant ones and up to 8 hours for LROPS compliant ones), so pilots can choose the safest airport with best facilities like medical, accomodation, food, clothing for sub-zero temperatures, for passengers in case of emergency, and no need to land at polar airports with poor facilities.
You said B777 is killing A340 on the sales book. The B777 sales book includes the shorter range models like B777-200 and B777-300. These 2 variants should not be compared with A340, and should be compared with A330 instead.
The total sales of A330 + A340 is BETTER than B777.