avformat/mux: call deinit if write_header fails