What software can turn off Wi-Fi automatically when closing lid?
You could combine DFGKApps's script for turning off Wifi and DssW's Power Manager to run the script on sleep.

The Terminal.app command to disable WiFi appears to be:

 networksetup -setairportpower en1 off


To re-enable WiFi use:

networksetup -setairportpower en1 on


Be sure to test these commands using Terminal.app, as I suspect they may require tweaking depending on your network set up.

Be aware that running a script on sleep does come with limitations. The time available for the script is short and can not be extended.

I am a software engineer involved with Power Manager, so feel free to ask technical questions about how to use it.