I am wondering: when an app is to be killed, does Android wait for the currently running function to return, or does Android stop it before it ends by itself?
Your app may be killed by the system at any time without another line of its code being executed. According to the documentation however, there are a few methods which are not "killable":
As onDestroy() won't get called for sure, it is more save to use the onPause() Method to write any persistent data to storage:
protected void onPause(){
super.onPause();
if(isFinishing()){
// store data
}
}