Motivated by recent experiments of Zajac et al. [Science 359, 439 (2018)], we theoretically describe high-fidelity two-qubit gates using the exchange interaction between the spins in neighboring quantum dots subject to a magnetic field gradient. We use a combination of analytical calculations and numerical simulations to provide the optimal pulse sequences and parameter settings for the gate operation. We present a synchronization method which avoids detrimental spin flips during the gate operation and provide details about phase mismatches accumulated during the two-qubit gates which occur due to residual exchange interaction, nonadiabatic pulses, and off-resonant driving. By adjusting the gate times, synchronizing the resonant and off-resonant transitions, and compensating these phase mismatches by phase control, the overall gate fidelity can be increased significantly.