update test_ccall to not use a postrun hook

This resolves https://github.com/kripken/emscripten/issues/1378

test_ccall was relying on the runtime being initialized during a postrun hook, which it isn't. However, since the current FS system wasn't destroying the streams during its teardown operation it was still working.

I've added JS interfaces for adding oninit, onpremain and onexit events, and updated test_ccall to using an onexit hook instead of a postrun hook.

I've also updated FS::quit to null out each stream entry.

Also to note, `return 0;` had to be replaced by a call to `exit(0);` to make the runtime actually exit when using callMain (as discussed https://github.com/kripken/emscripten/pull/1444).