pulsein() is a blocking call which polls a pin, and it uses a loop counter for timeout timing. very straightforward.
Switching devices on can cause spikes on other lines 'disrupting' the pin value causing pulseIn() to see it as a HIGH => stop measurement.
solution should be in hardware (no expert on that)