A particle of mass m and charge q is directly above a charge Q, held in place by a string of length d.  The string is cut.  How high does the charge q go before it comes to rest?  (The charge Q is fixed and does not move.)
 
 

The before and after states are shown below. The particle of charge q will be at rest in the final state.
 
 

I choose the reference level for gravitational potential energy at the level of charge Q.

Then:
 
  Before After
Gravitational Potential energy mgd mgh
Electric Potential energy kqQ/d kqQ/h
Total energy mgd+kqQ/d mgh+kqQ/h

 

So, setting total energy before equal to total energy after:
 

mgd + kqQ/d = mgh + kqQ/h
mg(h-d) = kqQ(1/d-1/h) = kqQ(h-d)/dh

The factor (h-d) cancels, leaving
h = kqQ/mgd