@Sivi 's answer closes the app. But on return, if you have some child activities, another unfinished activity might be opened. I added noHistory:true
to my activities so the app on return starts from MainActivity.
<activity
android:name=".MainActivity"
android:noHistory="true">
</activity>