cmd: Better type checking in CLEANUP_CMD_CLOSE macro.