Use cleanup handler in mac-specific semaphore implementation to allow it...

...s condition variable to be unlocked on thread cancellation