Why exactly do you expect the green line to exit in these spots?
Can't see it from your code.