Add main loop delay timer and fix Thread spawn surge in delayed close
magnetic valve.