Refactored sinproc shutdown code (fixes #31)

Tried to make the code as clean as possible. It's not like every other shutdown function in current nanomsg, so notify me if there is something wrong with it.

The patch is submitted under MIT License.