Move logic to finish emulated syscalls into Task.