Optimal control of entanglement via quantum feedback