Fix shutdown process

- make Close() wait til everything is cleaned up
- fix to avoid sending on closed channel in certain cases

Also: make the "metadata overhead" byte count exact in byteSize().