Better support for terminating the loop/context