Fix bugs in master

Ping @msmith-techempower and @aschneider-techempower for a code review before these changes are merged. I updated your port closing function quite a bit and fixed bugs that were preventing master from running properly. If this looks good it's ready to merge, but given how close you are to R10 I want someone to eyeball it before it hits master
Answer: it depends on HOW you kill the master: if it successfully shuts down with a sigterm, then it will (should) kill its children automatically; if it is killed via a sigkill, then it will NEVER kill its children.