How to restart WiFi connection?

You just need to restart Network Manager:

sudo service network-manager restart

These don't need root, in case you are scripting:

nmcli networking off 
nmcli networking on

For more do: man nmcli

EDIT:

As these guys are saying in the comments, for WI-FI only:

nmcli radio wifi off
nmcli radio wifi on