Shutdown gracefully on EOF