AppleScript: Close all Finder windows except the front one

I often end up with tons of Finder windows open. I usually realize this when I ⌘-tab to Finder and notice there are 20 windows. I generally want to keep the frontmost window but close all the others. Turns out there is a super simple AppleScript to do this (source):