Coherent control of entanglement with atomic ensembles