Refactor transport.write
Unregister reader on delayed closing