Fix race condition when exit/2,3 called

Fixes issue in commit 1003087.

Depending on the order when the fd's are closed, the control socket
could return from poll after the pid was zero'ed. Since the event loop
uses an event on the control fd to return an 'ok' message, the erlang
process would block forever in receive, waiting for a response from the
port.