Fix a crash bug in BeforeRun()

The mouse update function uses a _form field after it has been disposed, resulting in a NRE. This PR ensures that disposed Forms are correctly removed from the list of windows, which prevents the crash.

It also locks the Form collection to protect against a potential race condition (open a new Form while disposing an existing one.)
This would fix the immediate crash but leave the potential race condition when using multiple windows.