The World Endurance Championship and Formula E will lose three teams between them after carmaker Stellantis announced an end to its motorsport activities.