Listening for the home key to be pressed doesn't make much sense on Android since the user can leave your application by a lot of different ways.
What you can do instead is to override onStop() or onPause() depending on your paranoia level, and logout the user in this event.
You can find details on the lifecycle of an Activity in the official documentation : http://developer.android.com/guide/topics/fundamentals.html#actlife
I would suggest you to override these two methods with some debugging inside, try your application and decide in which you should put your logout() code.
@Override
public void onPause() {
super.onPause();
Log.d("MyTestActivity", "onPause()");
}
@Override
public void onStop() {
super.onStop();
Log.d("MyTestActivity", "onStop()");
}