Fix MAGN-4451 strange behavior with Run Automatic and Revit Document close/reopen.

@pboyer 

If all the documents have been closed and when we shut down Dynamo, there will be no valid documents for a transaction. An attempt to create a transaction will fail and an exception will be thrown. Also as the old transaction object has been disposed, it means the transaction object hold in the wrapper is invalid. This submission prevents the case by checking the document pointer when Dynamo is shutdown.