replaced whileM delay with STM.check. TODO : wait for children threads to gracefully exit