Hi Bruno,
From the CRM side, what will trigger the creation of a document ?
I am sure you understand that a page can be posted multiple times if the user click the refresh/back/forth button?
document.Close() will close the status of the current sales order. Not closing the object.
Regards
Edy