There should be something like a logout button which let's the user confirm they want to leave the app. On leaving, a flag should be set (maybe in localStorage) to know the app was closed manually. Bluetooth scanning should be disabled then and the app be closed. On resume(), the flag should be checked in order to start scanning again.
You need to be logged in to add a comment.