Evil people caught David in a net, and he prayed that God might pull him out of the net. David also prayed,
Into Your hand I commit my spirit; You have redeemed me, O LORD God of truth. (Psalms 31:5)
Whatever happened, David just wanted God to take care of him. Therefore, David committed his spirit to God, knowing that He would deliver David out of the net or do whatever was best.
Jesus quoted this verse when hanging upon the cross, which was like a net from which no bird or fish can escape. Therefore, Jesus committed His spirit to the Father and He delivered Jesus in God’s own way.
God rules over all anyway, so why not commit your spirit to Him and quit trying to force the outcome of your life your way. The Father is waiting for your commitment.