Disable Taxonomy Archive

Sometimes we do not want our custom taxonomies to have archive pages. Lots of reasons for this, yet there doesn’t seem to be a good solution for this. I would love to see WordPress implement a ‘has_archive’ flag for taxonomies someday. Until then we can use this function to return a 404 for any taxonomy archives we do not want shown to users.