The modular invariance of the one-loop partition function of the closed bosonic string in four dimensions in the presence of certain homogeneous exact pp -wave backgrounds is studied. In the absence of an axion field, the partition function is found to be modular invariant and equal to the free field partition function. The partition function remains unchanged also in the presence of a fixed axion field. However, in this case, the covariant form of the action suggests summation over all possible twists generated by the axion field. This is shown to modify the partition function. In the light-cone gauge, the axion field generates twists only in the worldsheet σ-direction, so the resulting partition function is not modular invariant, hence wrong. To obtain the correct partition function one needs to sum over twists in the t-direction as well, as suggested by the covariant form of the action away from the light-cone gauge.