iv_handle: Fix deadlock when unregistering handles from DllMain().

For the win32 port, if a thread that has called iv_init() but not
iv_deinit() returns from its start routine, the cleanup that would
normally have been done by iv_deinit() is done from libivykis's
DllMain() function, which is a function that Windows dynamic link
libraries can provide to receive notification of thread creation
and termination.

As part of this cleanup, all handle poll threads created by the
current thread that are still running are sent a kill signal and
collected.

However, it appears that calls to DllMain() are serialized under
a critical section, which makes waiting for another thread to
terminate from within a DllMain() handler guaranteed to deadlock,
as the terminating thread will try to enter the DllMain() critical
section on the way out, which will be held by the waiting thread
as long as the terminating thread hasn't terminated.

Work around this by having terminating poll threads signal an event
handle specially created for this purpose, and wait for this event
handle when shooting down a poll thread instead of waiting for a
thread handle corresponding to the poll thread.  This avoids the
abovementioned deadlock scenario.

Signed-off-by: Lennert Buytenhek <buytenh@wantstofly.org>