There are prettier ways, but the brute force way is to define distance in terms of t, take the derivative and equate it to 0, solve for t, and plug it back into the equation (checking 2nd derivative is > 0 for min)
It's easier to do this for d2 given that d is positive (The minimum will be the same)
d2 = (1+t-1)2 + (-1+t+3)2 + (-1+t)2 = 3t2 +2t + 5
d(d2)/dt = 0, solve for t and plug into the equation for the line to find the closest point.