I shall describe three approaches to manipulate the activity of neural circuits in closed loop. (i) By modulating illumination intensity as a function of the local field potential we can use optogenetics to achieve dissociable control of the phase, amplitude and frequency of gamma oscillations. (ii) We have shown that viral expression of a glutamate-sensitive chloride channel both suppresses seizures and rescues comorbidities in a mouse model of temporal lobe epilepsy. (iii) By placing a potassium channel under the control of an immediate early gene promoter, we can selectively inhibit overactive neurons without affecting intermingled neurons, a potentially versatile approach to treat disorders of circuit hyperactivity.