You need to listen for a popstate
event and change the page back.
addEventListener('popstate', function (event) {
event.state; // this contains the state data from `pustState`. Use it to decide what to change the page back to.
}
See also, MDN.