Edit: OnDestroy now exists in Unity 3.2. No need for hacks anymore!
Use OnDisable. You can determine whether the script is being disabled or the object is destroyed/deactivated like this:
NOTE! The above code longer works the same in Unity 3. It works like this instead, which seems less useful: