Did the machine gun contribute to the ending of world war 1?

No. There was a stalemate on the Western front because of the machine gun and barbed wire. Then the English, under Winston Churchill, invented the tank, and the tank along with the fresh American troops who recently joined the Allies, helped to end WWI in the west.