Be nicer, return error code when unlocking mutex

Applications are very likely to crash if they unlock a mutex they
do not own!