David is asking God to rescue him. We don't know how David was delivered but given the fact he died of old age, I trust that he was rescued. Praise the Lord, we serve the God who is capable of rescuing us out of the worst of situations if we are willing to trust His guidance.
The phrase, "I flee unto thee to hide me" poses an important question. How does one hide in God? It is simply a poetic way of saying we trust in Him for the outcome of our situations.
In verse 10, the Psalmist ask God to teach him God's will. So how do we learn God's will? It is mainly by studying His word. Sometimes He directs us from what we learn from other people and sometimes directly through prayer. The fact is simply that God does direct us if we are willing to listen to His direction.
Notice the word "Spirit" in verse 10. This is a subtle reference to the spirit of God (i.e., Holy Spirit) working to guide our lives. It is the Spirit who guides us close to God the Father. The Spirit tells us when we hear things that are godly wisdom. John 16:13 says, "Howbeit when He, the Spirit of truth, is come, He will guide you into all truth: . ." David is specifically asking for the Spirit of God to draw him close to God the Father. Did that mean David understood the theological aspects of the Holy Spirit? I doubt it. David knew there is the "Spirit of God" that guides us by making it obvious to us what is His will at any given moment.
Verses 11-12: [11] Quicken me, O LORD, for thy name's sake: for thy righteousness' sake bring my soul out of trouble. [12] And of thy mercy cut off mine enemies, and destroy all them that afflict my soul: for I am thy servant.
David wraps up this prayer by affirming that He trusts in God's righteousness and not on his ability to get out of trouble. He appeals to God's faithful love when asking Him to destroy his enemies. David trusts in God's ability to bring his problems to an end. Every believer ought to trust in a perfect God who knows all things, including the good and bad parts about our life. He is more than capable and willing to guide our lives and protect us as we trust in Him. Therefore, since we trust in His protection, and it is our desire to do His will, we go forward in life making the best decisions possible and at the same time trusting in this perfect God to guide us.