Fix race in finishing builds that have been cancelled

Created by  Eelco Dolstra  on August 6, 2015
X2LETBPI7VE2PT7SMFZH2X5I244IPBPIXMVLHN5TQIHAQPMQ2MQQC
Change contents