Volkswagen is planning to shut at least three factories in Germany and lay off tens of thousands of staff.