In 1 Samuel, Saul, who at that point was still king, tried to kill David. Saul's heart was filled with jealousy over David's success and his popularity with the people of Israel and Judah. Saul was also afraid because he knew that the Lord was with David, but had departed from him (1 Samuel 18:12). Saul tried to pin David to a wall with his spear, but David managed to escape (1 Samuel 19:10). Saul then sent some of his men to watch David's house and kill him in the morning. But David's wife, Michal, warned David of Saul's intent and then helped him to leave the house unseen (1 Samuel 19:11).
David knew that his escape from death was not his own doing. It was God's hand on his life that made it possible. David recognized it as God's protection and later memorialized it in song (Psalm 59). David praised God for His protection, for His strength, and for His love and mercy. In verse 16, David wrote:
But I will sing of Thy power;
Yea, I will sing aloud of Thy mercy in the morning:
For Thou hast been my defence
and refuge in the day of my trouble.
(Psalm 59:16, KJV)
When we are in our day of trouble and we can't see a way out of it, we should turn to God. He is all-powerful and He is able to provide the help, the refuge, that we need. When He does, we need to be like David. We need to sing His praises aloud. We need to praise Him for His love, His mercy, and His mighty power.