None of this is right. To turn off do:
digitalWrite (pin, LOW);
The interaction with the internal pull-up is completely avoided. Keep it as an output, for it is an output, no need to float the pin. If the sensor is down a long cable keeping the pin LOW will
potentially reduce noise pickup from it too.
Also don't try to power a whole chip with its decoupling capacitors from a digital output, that's going to have
big current spikes and needs proper switching with a PNP transistor of p-channel FET. A simple voltage divider
with < 1mA flowing is OK though.
Be aware that digital pin output drivers have about 40 ohms of internal resistance so are not
suitable for high accuracy work without taking that extra resistance into account. Something like
a 10k thermistor in series with a 10k resistor is reasonable though.