Use a done channel to kill off remaining goroutines

This patch ensures that goroutines which exist after the calculation has completed are killed accordingly (since the calculation has already completed -- no need to keep on trying).