Signaling threads that are waiting on mutexes

It seems that it’s not possible to abort a thread that is waiting on some mutex:

?- mutex_create(M), mutex_lock(M), thread_create((mutex_lock(M), write(never_here)), Tid).
% then later after thread has had opportunity to start:
?- thread_signal($Tid, abort), thread_join($Tid, Result). % stuck

Is there a way around it?

I understand that (following the docs), the thread that is waiting on a mutex will never have opportunity to receive the signal. But maybe abort or some other kind of fatal signal should have special treatment and allow killing “stuck” threads?

Works fine on Linux, be it slow. This requires pthread_mutex_timedlock() though, which does not exist on all platforms. I know of no reliable way to achieve this in a portable way.

Also on Linux, it is merely intended for interactive usage as the target thread may delay up to 0.25 sec.

Mutexes should in general be avoided. The rather complicated Prolog control flow, including exceptions, failure, backtracking and non-determinism make it really easy to deadlock when using mutexes. If unavoidable, use with_mutex/2 and make sure the called goal will terminate quickly. If broken into lock and unlock, use setup_call_cleanup/3 and again, make sure there is a cleanup quickly (notably in this case, do not leave a choicepoint).

What is the more high level goal?