How to abort a macOS installation loop
I noticed a lot of people having trouble with this so thought I'd post.
If you've downloaded Mac OS Sierra on your MacBook but either the file is corrupted or you've run out of disk space, it's near impossible to get out of the loop when restarting your computer.
When you reboot, a dialogue box saying 'Mac OS cannot be installed' will pop up. Click anywhere on the box and the top bar menu will appear. Go to Disk Utility and select the greyed out Macintosh HD then press 'Mount' - this will take a few moments. If you want to hedge your bets click on Mac OS Sierra and select 'First Aid', to try and repair any issues with it.
Once Macintosh HD appears as a mounted drive, go back into the top menu, click the Apple logo and select 'Startup Disk'. Mac HD will appear, select it and then you can click 'Restart' on the installation box.
A nightmarish problem with a fairly simple solution. I learned the hard way. I hope this helps.