Buffalo won a Thanksgiving thriller with a long field goal late, spoiling Detroit's hopes at an overtime upset.