Back Buttons and PDF's or JPG Popups

We have a app for a phone book
some of the listings have pdf’s that popup with an ad

this is fine and the pdf’s do popup

a person selects a phone book and searches for a name’
this produces a list, some of the line items have ads, click the ad (which is a PDF) and it loads in a lightbox, this is all fine
but when you click the bottom navigations back button, it does not take you back to the listing, it should just close and leave the listings, but instead it takes the user all the way back to the beginning and they have to do the name search all over again,

is there a way to have the pdf load and have a X to just close the popup and have the listings remain, we can convert to jpg’s if this will produce the x to close the popup and leave the listings

we have been trying to figure this out for a year, we use php and we are loading a mobile version of a website within an app