Do coroutines stay in memory after an object they are waiting for is destroyed?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sunDalik

So I have an asynchronous function that looks like this

public async void SomeFunction()
{
        entity.MoveToPosition(position)
        await ToSignal(entity, "move_completed");
        // Run some other code
}

The question is: What will happen if the entity gets freed before it emits move_completed signal? Will the coroutine just get stuck in memory? Will it run the code after? Will it get freed immediately?

If it will stay in memory what can I do to prevent it?