The changing rotation period of comet 67P/Churyumov-Gerasimenko controlled by its activity