That's the static energy built up on the car; used to happen to me also on one of our cars.

On how to avoid it, there are some suggestions on google but you have to try them for yourself.