Issue title: DOMException : Failed to execute "send" on 'RTCDataChannel'
 Issue body: **Browsers and versions affected**
Chrome 63 and above

**Description**
While trying to generate and send data, the page tries to execute 'send' in a state where the channel is already closed. Its also visible in the UI, the send progress is stopped about 99%.

**Steps to reproduce**
Go to webrtc.github.io/samples/src/content/datachannel/datatransfer/
Click on Generate and send data 
(Ordered mode checkbox has been checked)

**Expected results**
No javascript failures 
All the data has been sent
**Actual results**
DOMException and not all the data has been sent.

Note: Tested in MAC, and Linux, and the issue available in both the platforms. 
![dom-ex](https://user-images.githubusercontent.com/32895099/34672310-3f96c1c0-f47e-11e7-9c9e-f8d387d28550.png)

10.869:  Closed data channel with label: sendDataChannel
common.js:6 10.880:  Closed peer connections
main.js:140 Uncaught DOMException: Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel.readyState is not 'open'
    at sendAllData (https://webrtc.github.io/samples/src/content/datachannel/datatransfer/js/main.js:140:19)
    at RTCDataChannel.listener (https://webrtc.github.io/samples/src/content/datachannel/datatransfer/js/main.js:123:5)
sendAllData @ main.js:140
listener @ main.js:123
common.js:6 10.886:  Send channel state is: closed
  
 Comments: 
 Comment 0: Looks like a race condition that happens sometimes, its not a functional issue hence it's not a priority to fix.

Most likely some data that has been queued up due to filling up the the data channel and it backs off and retries and in some cases the retry happens after all data has been sent.
Basing this on the comment https://github.com/webrtc/samples/blob/gh-pages/src/content/datachannel/datatransfer/js/main.js#L126-L129
 Comment 1: Same Problem here. Any Workarounds?
 Comment 2: I think this is related to #894 

If so, see my comment on redesigning the protocol for this sample by sending the size of the data in the first message. Anyone disagree?
 Comment 3: Closing this as this shouldn't be possible anymore.
 Comment 4: I'm getting the same exact error:

```
Uncaught DOMException: Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel.readyState is not 'open'
```

With this simplest code example:

```js
pc = new RTCPeerConnection({ "iceServers": [{ "url": "stun:116.69.203.115:6120" }] })
dc = pc.createDataChannel("channel")
dc.send('123')
```
{'source': 'GithubIssues', 'repo_name_with_owner': 'webrtc/samples', 'issue_id': 286741452, 'repo_stars': 12328.0}