try this after the process

if de.rscommand.state=1 then de.rscommand.close