Close SQL session properly.