Everything God does is intentional and produces the expected result. He does not react or get surprised by what happens. As our lives unfold before us, it may seem as if God is constantly course correcting because of our mistakes, but that is not the case. What we perceive as a turn of events is really God exercising his control, showing us that he is able to accomplish a desired outcome with or without our help.
So Saul died for his transgression which he committed against the LORD, even against the word of the LORD, which he kept not, and also for asking counsel of one that had a familiar spirit, to inquire of it; and inquired not of the LORD: therefore he slew him, and turned the kingdom unto David the son of Jesse. (1 Chronicles 10:13-14)