Canada's Brady Leman won gold in a crash-marred men's ski cross finals in freestyle skiing at the Winter Olympics.