Psalms 40:14
Let them be ashamed and confounded together that seek after my soul to destroy it; let them be driven backward and put to shame that wish me evil. Let them be ashamed and confounded together that seek after my soul to destroy it; let them be driven backward and put to shame that wish me evil.
The last five verses of Psalm 40 form a distinct closing unit that reappears as Psalm 70 with slight revisions. That closing portion belongs to different circumstances from the earlier verses of the psalm. It is a personal plea for God to put to shame, confound, and drive backward those who seek after life to destroy it and who wish evil and delight in harm.
The psalm as a whole expresses human need moving toward triumph and confidence in God, pointing to a God who is able and willing to save. It is especially prophetic of Christ, giving a prophetic picture of His inner experience including life-and-death struggles with the enemy, and because He stood on behalf of humanity it applies to believers. In that prophetic sense the verse shows enemies seeking to destroy Christ and wishing Him evil, and it depicts their defeat and shame.
Such a prayer for shaming and turning back enemies is not retaliatory when inspired by the Spirit, but expresses what God wills to do against those who oppose His cause, whether spiritual enemies or human enemies acting against Israel and David as its ruler.