A recurring theme in several Jin Yong stories is having the protagonist coming into the favor of and serving a powerful king, and eventually betraying that king when continuing to serve the king conflicts with the protagonist's conscience or self-interest in some way. Cases in point:
Kiu Fung (DGSD): served Khitan king Yeh Lut Hung Gei, but eventually turned against the king to prevent a war between the Khitan Liao Empire and the Northern Sung Kingdom. Kiu Fung betrayed Yeh Lut Hung Gei in the name of peace, and then took his own life as penance for betraying his liege and sworn brother.
Gwok Jing (LOCH): served Genghis Khan in the wars against the Jin Empire and its allies, but turned against Genghis after the Khan had caused Gwok Jing's mother to commit suicide and after it was clear that Genghis planned to lead the Mongol forces to invade the Southern Sung Kingdom. Gwok Jing spent the rest of his life fighting against Genghis' descendants and successors.
Wai Siu Bo (DOMD): served Emperor K'ang Hsi, but turned against the emperor when the emperor ordered him to eliminate his Han kinsmen in the Heaven and Earth Society.
This seems to be a popular theme with Jin Yong, as he visited it three times with three different protagonists in three different eras of Chinese history.