HTC programmed the WiFi to disconnect when the signal drops below -88 dB. I guess they thought a connection weaker than that threshold would drain the battery quicker than they would like, but they were clearly a little aggressive. Anyways, I lowered the disconnect threshold to -108 dB and my phone is holding on to my WiFi connection really well now.
Fixing the issue (experienced devs only):
Add the line "rssi_offset=-20" to /system/etc/calibration. It fixes wifi stability, but it throws off the signal indicator display, so now we need to fix that.
After setting that line in /system/etc/calibration, you need to decompile and edit some smali in framework.jar. There are seven RSSI values in /framework/classout/android/net/wifi/WifiManager.smali that need to be edited. Two defines in the beginning of the file (MIN_RSSI and MAX_RSSI) and five more in the calculateSignalLevel function. They need to be adjusted by the same amount you set in the calibration file.