This is default behavior on android. For usability reasons, the back button should always consistently get you back to the home screen eventually.
I believe you can interrupt this flow, against Google design recommendations, by opening a dialogue when the back button/guesture is called asking if the user is sure they want to quit. If the back button is pressed while the dialogue is open, it simply closes the dialogue.
Basically make a situation where the back button is handled by an event/action of your own choosing at all times. Iirc there were also JavaScript options to disable the back button completely, but that would be decidedly unfriendly to your end users.