Fix a hang at shutdown when the main thread finishes faster than the worker threads initialize.
Fix MallocAllocator.realloc to shift the returned memory when the alignment changed. Fixes #454.

The previous copy from the old memory region was using the already freed memory.