Prevent hang on shutdown race.

This commit prevents a race that could happen on shutdown if a sigint was
received between adding the first the interrupt handler and and future
handlers.  This code is loosely based on initial pull request #154 which
was not accepted due to introducing a race of its own.

Thanks to @tuxcanfly for the intial pull request and finding the issue.
updated utils to handle regtest, simnet

handle active network assignment in the same if-else
instead of having another switch-case
IMPORT PATH MODIFICATION CHANGESET
----------------------------------

Please use this changeset as the first one on top of the conformal codebase.
Note that if there are new imports, they need to be changed as part of this
changeset. In general, use "git rebase" on github.com/conformal's version
and apply this changeset first.