You could rewrite your script as:
Allow User Abort [ off ]
If [ IsEmpty ( ARTWORK::_fkInvoiceID ) ]
Set Variable [ $discount ; INVOICES::Discount After Production ]
Go to Related Record [ ARTWORK ; Layout: Artwork ; matching only ; match current only ; New Window ]
Replace Field Contents [ ; no dialog ; target field: ARTWORK::Split Discount ; calculated result: $discount / Get ( FoundCount ) ]
Thanks so much
You might have had more windows open than you "saw". Especially when debugging and stopping a script halfway does this :-)
I name my temp windows "temp" and when developing I have script at the beginning that closes all temp windows :-)
Go to Record/Request[Exit after last]
This script step is the problem. The Exit after last option is commonly used inside a loop but when it's not, it exits the script. It's a bizarre little aspect. What's happening is when you have one record, that script step exits the script skipping the rest, including the Close Window.
From the help:
"Exit after last tells FileMaker Pro to stop the script when it reaches the last record in the found set. You can use Exit after last with the Loop script step to exit out of a loop after the last record."