Close window immediately after delete record
I think it is something easy, but I can not find it.
I open an new lay out in a new window. The new window is "Dialog". In this lay out only adding is allowed. So I open the window with a script "new record". Everything is working.
On this lay out I have a button to delete the record that was added (in case the user makes a mistake and wants to go back). Normally, after deleting the record, you get te next record in the lay out. I do not want users to change records in this lay out. So I made a simple script for the delete button: first delete the record and then close the window. Closing the window is not working after deletion. The strange thing is, that I have another button that only closes the window, that works fine.
This is what I used. (Translated);
Delete record [No Dialog]
Close Window 
I thought it had perhaps something to do with another script still running, but that is not the case. (I added "stop script", but with the same result.
Can someone help me out with issue?