The Nationalists ruled mainland China until 1949 , when they lost a civil war to Mao Zedong 's communist forces .