The best solution I have found for this (thanks to @Colin) is
[{"id":"fbd3a65b056cdd0d","type":"inject","z":"523968221e696a28","name":"message in","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":170,"y":620,"wires":[["a2fe8de8ecc0501d"]]},{"id":"cc86232451944c83","type":"inject","z":"523968221e696a28","name":"open","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"open","payloadType":"str","x":350,"y":660,"wires":[["e8464d1608046ae7"]]},{"id":"a2fe8de8ecc0501d","type":"function","z":"523968221e696a28","name":"close after","func":"return [[msg,{payload:'close',topic:'control'}]]","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":620,"wires":[["e8464d1608046ae7"]]},{"id":"e8464d1608046ae7","type":"gate","z":"523968221e696a28","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","statusCmd":"status","suppressWarnings":false,"persist":false,"storeName":"memoryOnly","x":490,"y":620,"wires":[["69207b01cfe27d1f"]]},{"id":"69207b01cfe27d1f","type":"debug","z":"523968221e696a28","name":"message out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":620,"wires":[]}]
The function
node ("close after") On Message tab contains just the single line of code
return [[msg,{payload:'close',topic:'control'}]]
This should eliminate the possibility of a race condition. (As I understand how NR handles messages, it is not possible for any message to reach the gate in between the two sent by the function
node.) For the record, and in case you are interested, aspects of this issue have been discussed here and here.