You can close a drawing in that manner, however, you should note that there are a couple of caveats. If you attempt to close the current drawing, an error will be generated, also, if you close the drawing then attempt to perform an operation that relied upon any variables set in the noe closed drawing, an error will be generated.
Without having the specific code it will be hard to determine what the error is, but suffuce to say I have not been able to duplicate it.