Sticky sidebar stop at specific position on scroll


I managed to create a sticky sidebar following this guide:

I am wondering how to stop the sticky at a specific point as I continue scrolling down.
Ex. I would like to stop the sticky sidebar before I reach the footer.

I have not been able to figure out how to do this.

deleted my reply. It was not relevant to Jason’s question.

If navbar goes below footer, would that be a good enough of solution?
This type of aproach from above doesnt allow you to easily disable sticky navbar when you want it, but you can create some sections such as footer to have higher z-index than navbar, and you will have an effect that navbar goes under to footer.

If you want to get an effect like we have on pricing page for example, when you are scrolling down, your navbar is hidden, and when you start scrolling to top, navbar is shown. If you need such an effect? I can create a tutorial soon, it requires a bit of JS, maybe I will create a plugin as well.

The nav bar effect on the Divhunt’s Pricing page would do wonderfully for what I am looking after.

A tutorial + plug-in would be a great help!
Thank you.