Update index.js

fix 'end' event to match typical node callback symantics