node: invoke `beforeExit` again if loop was active

When `setImmediate(cb)` is called in `beforeExit` event handler the
consequent `uv_run(..., UV_RUN_NOWAIT)` may return `0`, even if there
was some active handles at start.

Fixes simple/test-beforeexit-event.js.
smalloc: remove `env.h` include

Since `smalloc.h` is included in a `node_buffer.h`, including private
headers in it is strictly prohibited.

fix #7206