Fix for crash when disposing a null object.