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?
The OS kills the JVM process, with all the "functions" in all the threads. In practical terms, you shouldn't assume that a method is a transaction. Instead, one should assume it can be terminated at any time and design appropriately.