                                             button_mouseDownHandler);
             maximizeButton.removeEventListener(MouseEvent.CLICK,
                                             maximizeButton_clickHandler);
-            DisplayObject(window).removeEventListener(
+
+            var targetWindow:DisplayObject = DisplayObject(window);
+            targetWindow.removeEventListener(
                 NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE,
                 window_displayStateChangeHandler);
+            targetWindow.removeEventListener(SkinPartEvent.PART_REMOVED, partRemovedHandler);
         }
         
     }

                                            button_mouseDownHandler);
            maximizeButton.addEventListener(MouseEvent.CLICK,
                                            maximizeButton_clickHandler);
            DisplayObject(window).addEventListener(
                NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE,
                window_displayStateChangeHandler, false, 0, true);
        }
    }


import spark.components.Button;
import spark.components.supportClasses.SkinnableComponent;
import spark.components.supportClasses.TextBase;
import spark.events.SkinPartEvent;
import spark.primitives.BitmapImage;
import spark.skins.*;
import spark.skins.spark.windowChrome.MacTitleBarSkin;
