Volkswagen has announced a deal with European unions to avoid factory closures in Germany and massive strikes.