Sometimes you just want to hide from God. I'm sure David did. You're ashamed of your imperfections, and you just want to dig a hole somewhere, crawl in, curl up, and die.
But David saw how fruitless those efforts would be. You can't hide from God! He made the universe, so where are you going to hide? God loves us so much, He will ALWAYS be with us.
The end of Psalm 139 reminds me of the end of Psalm 19. In both of them, the psalmist is asking for God's help to live a God-pleasing life.