Fix bug in remqueue in threads.c when removing last element.