If we are given a line with scalar parametric equation $$x=x_0 + ta$$$$y=y_0+tb$$$$z=z_0+tc$$ And we want to obtain the point $Q$ of the line closest to the point $P$, then we could proceed as follows. First find the value of the parameter $t$, corresponding to point $Q$, by taking the dot product $$\bar P \cdot (x_0+ta,y_0+tb,z_0+tc)=0 $$
If $Q$ is the point closest to $P$, the line between them must be perpendicular. We obtain parameter $t$ from this equation and obtain $Q$. Is this a valid method?
The idea is right, but that's not what you wrote in the formula. Your $Q$ is given by $(x_0+ta,y_0+tb,z_0+tc)$. Then you are interested in the line between $P$ and $Q$, which is $$PQ=(p_x,p_y,p_z)-(x_0+ta,y_0+tb,z_0+tc)$$ Also, the direction of the line is not the same as the direction of $Q$. You can choose two points on the line, and write the difference. The best ones in your case are $Q$ and $(x_0,y_0,z_0)$. So the vector for the line is $(at,bt,ct)$.