Fixed destructor in named semaphores

- sem_destroy() is not implemented in OS X.
- Unnamed semaphores should use sem_close() instead of sem_destroy().