They got rid of the foreign gods among them and they worshiped Yahweh. Then Yahweh could bear Israel's misery no longer.