Added JavaScript example code to README + Moved w.close() inside callback of the last w.publish

* Added JavaScript example code to README
* Moved w.close() inside callback of the last w.publish
Merge pull request #28 from pilwon/patch-1

Added JavaScript example code to README + Moved w.close() inside callback of the last w.publish