JaVale McGee rebounded a missed free throw following a basket with five seconds remaining and dunked to give the Nuggets a 116-115 win over the Detroit Pistons on Wednesday night.