correct processing of commands after close