AppleScript & Opening/Closing Apps

I'm sending via email a file using Hazel, Mail.app and some AppleScript.
If I have Mail open when the action runs, afterwards I can close it as usual.
If the AppleScript opens the Mail app, then I have to force quit it.
I don't want to make the AppleScript quit Mail as it may not have sent the message.
Ideally I would want to either close Mail once the message has been sent, or to be able to close it manually using CMD-Q or the menu.
I suspect this is an AppleScript challenge but I'm having trouble finding help as I don't know why this behavior exists. I suspect it's because Hazel is working at the System Events level.
Any pointers much appreciated.
If I have Mail open when the action runs, afterwards I can close it as usual.
If the AppleScript opens the Mail app, then I have to force quit it.
I don't want to make the AppleScript quit Mail as it may not have sent the message.
Ideally I would want to either close Mail once the message has been sent, or to be able to close it manually using CMD-Q or the menu.
I suspect this is an AppleScript challenge but I'm having trouble finding help as I don't know why this behavior exists. I suspect it's because Hazel is working at the System Events level.
Any pointers much appreciated.