Merge "Exit the loop at the right time" into pi-dev
am: 6d24a1c8be

Change-Id: Idbf0953a3fb4dd38640009a0b213dace99a282c5