Fixing null pointer issue when detaching the widget on editor close.