Use a separate thread for the whole shutdown procedure on Android, remove the broadcast receiver first