We describe a fast closed-loop optimization wavefront shaping system able to focus light through dynamic scattering media. A MEMS-based spatial light modulator (SLM), a fast photodetector and FPGA electronics are combined to implement a closed-loop optimization of a wavefront with a single mode optimization rate of 4.1 kHz. The system performances are demonstrated by focusing light through colloidal solutions of TiO2 particles in glycerol with tunable temporal stability