What is the purpose of netcat's "-w timeout" option when ssh tunneling?

What is the purpose of that -w 3 in the original solution

It avoids leaving orphaned nc processes running on the remote host when the ssh session is closed improperly.

and why is it causing a Broken pipe error when I use it?

Try increasing the timeout for nc to 90 and setting ServerAliveInterval to 30 to see if your problem go away:

host foo
    User webby
    ServerAliveInterval 30
    ProxyCommand ssh a nc -w 90 %h %p