The Zhou Dynasty ruled China from 1040 BC to 221 BC. It began when the Zhou overthrew the Shang Dynasty due to the Shang emperor's immoral behavior. The Zhou established a feudal system to control its large territory. However, later emperors like Zhou Youwang performed poorly, angering citizens. Youwang was killed in an invasion, signaling the Zhou had lost the Mandate of Heaven. This led to wars between seven provinces as they fought for control. Eventually the Qin province emerged victorious, ending the wars and establishing the Qin Dynasty to rule all of China.