Stop main loop from main loop context

Change-Id: Ia033d363285d5a067f69f5b1c149ab9c44518c95