Follow the Path, but is it valid?
JavaScript (ES6), 219 bytes
Takes input as a list of lists of characters.
a=&gt;((g=(X,Y,D,n=o=0)=&gt;!(a+0)[n++]|a.some((r,y)=&gt;r.some((c,x)=&gt;D=='975'[i='-| #+$'.indexOf(c),x-X+1]-'450'[y-Y+1]?i-3?i-2?i&gt;3?[3,0,7,4].some(d=&gt;D^d^4&amp;&amp;g(x,y,d,n)):~i&amp;&amp;i^D&amp;1?0:g(x,y,D,n):0:o=-n:X+1|i&lt;5?0:g(x,y,2))))(),~o)

Try it online!
How?
Because they need to be tried in a specific order, the way the directions are handled in this code is a bit unusual.
Given a direction \$D\$ and the source coordinates \$(X,Y)\$, we want to figure out which target coordinates \$(x,y)\$ correspond to a move by one square along \$D\$.
We use the following test for each candidate pair \$(x,y)\$:
D == '975'[x - X + 1] - '450'[y - Y + 1]

This test always fails if \$|x-X|&gt;1\$ or \$|y-Y|&gt;1\$ because we get an undefined value from at least one of the 2 lookup strings.
Otherwise, we have the following table:
$$\begin{array}{r|c|ccc}
&amp;x-X&amp;-1&amp;0&amp;+1\\
\hline
y-Y&amp;&amp;9&amp;7&amp;5\\
\hline
-1&amp;-4&amp;5&amp;3&amp;1\\
0&amp;-5&amp;4&amp;2&amp;0\\
+1&amp;-0&amp;9&amp;7&amp;5
\end{array}$$
Because diagonal moves are not used, our final compass looks as follows:
$$\begin{array}{cccc}
&amp;&amp;3\\
&amp;&amp;↑\\
4&amp;←&amp;2&amp;→&amp;0\\
&amp;&amp;↓\\
&amp;&amp;7
\end{array}$$
The lookup values were chosen in such a way that we end up with some handy properties:

Opposite directions can be detected by testing if \$d\operatorname{xor}d'=4\$. Hence the code to try all directions in clockwise order except the one that would make us going back the way we came:
    [3, 0, 7, 4].some(d =&gt; D ^ d ^ 4 &amp;&amp; g(x, y, d, n))


Vertical moves are connected to odd values.

Horizontal moves are connected to even values (except direction \$2\$, for no move at all, which is only used at the beginning of the process when the starting point has been identified).