hooks.c: handle invalid mutex in pthread_mutex_destroy

Patch originally done by Ricardo Mendonza (ricardo.mendoza@canonical.com).

Return EINVAL if mutex is invalid (instead of crashing with a segfault).