Detecting user exiting a book online

how can i know a user of my app about books has exited the page where he was reading a certain book he chose to read ?
so whe he clicked or touched his “back” phone button for example.