I was about to say tha it sounded dumb to me as switching the wifi card on and off takes a lot of battery power, as does having something open in the background, but since I read there was an app out that did that in @Vincentt‘s answer, I thought i’d check my assumption against the reviews.
Lo and behold:
Jim Henderson
Does what it says but doesn’t help
Well as an IT director I tried this app on 4 different phones and it worked flawlessly on all. However over the 2 week test every user reported the battery dying much quicker than just leaving WiFi on 100% of the time, so evidently the theory of WiFi off except when connected to a network saving battery is incorrect. Tested on galaxy s4 and s5 HTC one m8 and LG Flex
So yeah, my doubts are confirmed, if you want that to work you’ll have to rely on your own brain and manual skills because having periodic checks burns more battery than it saves.
Edit: Wi-Fi Matic uses location tracking, not periodic wi-fi checks, so my assumption may yet be incorrect, as location tracking, especially GPS, is extremely battery intensive. Still, not a good app for what you’re looking for.