Michael,
If you wna this to occur everytime the fomr is released no matter how it is released, then put your code in the form's Destroy event. It fires before the contained objects have been destroyed.
The QueryUnload event only fires if the form is released using the Close (X) button or through RELEASE FormReference. If Thisform.Release() is called the form is released but the QueryUnload does not get fired. The Destroy gets fired for all methods of releasing the form.