This is a speculative fix when looking at the finalization code in Process. It tackles the following issues:
- Adds synchronization to prevent races between threads.
- Marks the process as finalized/invalid as soon as Finalize is called rather than at the end.
- Simplifies the code by using only a single instance variable to track finalization.
honestly the whole thing should be refactored, the mem-initializer list is kind of ridiculous.