What was the main reason the Middle Kingdom ended?