German insurer Allianz has announced it will phase out investments in the coal sector completely by 2040.