Fix random crashes due to disposing a form too early