* Adding a close method for graceful shutdown

@ronkorving could you have a quick look? I will test it further with some of our tools in the next few hours.
Can't we allow `cb` to be optional? I think it tends to be, with `close` functions.