java – How to destroy / kill an Android service?

I have my application running a service to detect jerks, but in my MainActivity, I have a button to disconnect the user, in which I have to log out and terminate the service that detects the Shaking event.

my method of disconnection in MainActivity is as follows:

public void signOutAndFinish () {
// Stop Shakeservice
Intention of intent = new intention (this, ShakeService.class);
stopService (intention);
// Go to connection activity
Intent iLoginView = new Intent (this, LoginActivity.class);
startActivity (iLoginView);
}

However, if I shake my device after logout, the service recognizes the tremor, it's like it's not killing it immediately:

Intention of intent = new intention (this, ShakeService.class);
stopService (intention);

The code in the onDestroy method is:

@Override
public void onDestroy () {
super.onDestroy ();
}

How can I terminate the service so that when I log out, the service dies?

Thank you for your help!