How to make sure that /taxonomy/term/24/WHATEVER gives 404? Google found up some weird links on my website and has started indexing stuff like /taxonomy/term/24/WHATEVER. I don't want that.

I also don't want to find all these URLs manually, ideally they will turn up in Google Webmaster's list of broken links and I can fix them using that list.

Unfortunately in the taxonomy term view at PAGE SETTINGS it just says Path: /taxonomy/term/%. Is there a good way to respond 404 on /taxonomy/term/24/WHATEVER addresses?
I've done something similar, but there might be some edge cases where this solution might not be suitable.

You can use hook_taxonomy_term_view() and within that check if the amount of arguments in the URL ($_GET['q']) is more than three.

/**
 * Implements hook_taxonomy_term_view().
 */
function custom_module_taxonomy_term_view($term, $view_mode, $langcode) {
  if (count(arg()) &gt; 3) {
    // This will throw a 404.
    drupal_not_found();
  }
}