Without being facetious, that strategy does work for this particular problem: turn off your wifi if you are walking around, traveling, or not in range of a network you intend to connect to.
I also have Bluetooth and NFC off most of the time since I rarely use them. (But then there's the cellular connection of my phone ...)
I'm not sure about iOS, but on Android this is possible with many apps in the app store. Some manufacturers also have "smart settings" in settings of Android that also gives this capability out of the box.
https://en.wikipedia.org/wiki/Robert_Morris_(cryptographer)