Close overlay on page scroll?

I would like my overlay to close when the user scrolls, or be able to control the z-order, so it scrolls under my pinned header. Any ideas on this? Right now my manual overlay scrolls with the page and scrolls over the top of pinned items, looking broken and glitchy.