Not only the wireless goes off, but the whole machine goes to sleep mode - disk spins down, CPU stops - the energy is only spent on keeping RAM alive. So, as you understand, in sleep mode downloads can't happen anyway.
The way to fix it is to adjust power settings to not to send the computer to sleep when the lid is closed. This, obviously, would result in power consumption similar to that when the lid is open.
UPDATE: If you already disabled suspend on lid close and the wireless still turns off, it suggests there may be some bug/glitch/misconfiguration in some versions of Ubuntu. I searched Ubuntu bug database but couldn't find anything similar - however, as this forum thread shows, there are other users who experienced similar problems.
So, if you really love to code as your avatar suggests, you may start from investigating
/etc/acpi/lid.sh script, which, as I understand, is invoked when the lid is closed, and go from there - hopefully you will be able to find the cause of the problem, fix the issue for yourself and then report the bug+solution to the Ubuntu bugtracker.