If I can give my opinion.
In my understanding of the Scriptures; When we sin, the Holy Spirit don't just leave us like that.
His work is to convince the world of sin.
When the believer sin, He convicts us of our sin, and strive with us.
Committing a sin does not drive out the Spirit, it grieves the Spirit. (Eph.4:30)
We are sealed with the Spirit unto the day of redemption.
Continuing in our sin, that quenches the Spirit, and causes Him to depart from us.
David understood that very well (Ps.51:11)
A believer can commit A sin [through weakness,ignorance, unintentionally], but can never practice [habitually] sin, and still be called a child of God led by the Spirit.
Just wanted to share my view on the Holy Spirit leaving us.