Motherwell secured second place in the Scottish Premiership against fellow challengers Aberdeen with a 1-0 victory at Pittodrie.