Wait for data to send when closing due to shutdown.