RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • close

close — Close figures or a session-owned TCP resource.

Bare close closes the current figure and succeeds when none exists. close('all') closes figures. A sealed TCP client or server, or the RunMat selectors 'clients' and 'servers', closes only resources owned by the installed TCP service.

Syntax

close
status = close()
status = close(target)
status = close(targets...)

Inputs

target
Type
Any
Required
Yes
Description
Figure number, sealed TCP receiver, or an admitted close selector.
targets
Type
Any
Required
Variadic
Description
RunMat-only separate close targets.
NameTypeRequiredDefaultDescription
targetAnyYes—Figure number, sealed TCP receiver, or an admitted close selector.
targetsAnyVariadic—RunMat-only separate close targets.

Returns

status
Type
NumericScalar
Description
Scalar double: graphics completion, or whether a TCP resource was closed.
NameTypeDescription
statusNumericScalarScalar double: graphics completion, or whether a TCP resource was closed.

Errors

RunMat:close:TooManyOutputs
When
More than one output is requested.
Message
close: too many output arguments
RunMat:close:InvalidArgument
When
A graphics target or TCP selector is invalid.
Message
close: invalid argument
RunMat:close:InvalidHandle
When
A TCP-looking receiver has no sealed socket authority.
Message
close: invalid handle
IdentifierWhenMessage
RunMat:close:TooManyOutputsMore than one output is requested.close: too many output arguments
RunMat:close:InvalidArgumentA graphics target or TCP selector is invalid.close: invalid argument
RunMat:close:InvalidHandleA TCP-looking receiver has no sealed socket authority.close: invalid handle
—The session-owned TCP service rejects or fails a close operation.close: TCP close failed
RunMat:parallel:CancelledAn invocation is cancelled while a TCP close is pending.close: cancelled
—A graphics target cannot be parsed or the selected figure cannot be closed.close: graphics close failed

Graphics forms

close, close(fig), and close('all') close the current, selected, or all figures. Successful and no-op graphics forms return scalar double 1. An explicit nonexistent figure raises its figure-handle diagnostic. CloseRequestFcn refusal is not implemented, so graphics status 0 is not currently produced.

RunMat mode additionally accepts exact host integer figure selectors and separate variadic targets. Numeric GPU targets are rejected before provider access. A cell of figure targets is not supported.

TCP forms

close(client) and close(server) use the receiver's sealed session authority. Closing a server also closes clients accepted from it. Closing an already-closed resource returns double 0; closing one or more live resources returns double 1.

close('clients') and close('servers') target the current session's TCP resources. Nested cells of TCP receivers are accepted in RunMat mode. The visible object class and properties are not socket authority; a forged or stale receiver cannot close another session's socket.

TCP closure requires the installed native TCP service. Browser TCP targets report the typed unsupported-target diagnostic after input admission; graphics close remains available in browser rendering. Cancellation is checked before and after each close. If cancellation or a later target fails after an earlier socket has closed, the call reports an error but that closure remains in effect; close does not replay or roll back earlier targets.

Additional workflows

A startup sequence such as clc; clear; close is safe with no open figures. For a loopback server, create s = tcpserver(...), accept a client, then close(s) to release both listener and accepted clients. Repeating close(s) returns 0.

RunMat networking selectors can close all clients or servers in a session. Use close('clients') and close('servers'), not close('all'): the latter belongs to graphics. A mixed figure/TCP target container is not admitted.

Examples

Close the current figure

figure(7);
assert(isgraphics(7));
status = close
assert(status == 1);
assert(~isgraphics(7));

Expected output:

status = 1

Close all figures

figure(8);
figure(9);
assert(isgraphics(8));
assert(isgraphics(9));
status = close('all')
assert(status == 1);
assert(~isgraphics(8));
assert(~isgraphics(9));

Expected output:

status = 1

Close a loopback TCP client

client = tcpclient('__RUNMAT_LOOPBACK_HOST__', __RUNMAT_LOOPBACK_PORT__);
write(client, uint8(9));
status = close(client)
assert(status == 1);
assert(close(client) == 0);

Expected output:

status = 1

Using close with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how close changes the result.

Run a small close example, explain the result, then change one input and compare the output.

FAQ

Can close be called twice?⌄

A repeated TCP close returns 0; a repeated explicit figure-number close raises the missing-figure diagnostic. Bare close with no current figure succeeds as a no-op.

Do GPU arrays require a kernel?⌄

No. Figure and TCP targets are host-managed. Resident numeric figure targets reject without a provider download.

Source you can read

Every RunMat function's source is public. Read exactly how close is executed, line by line, in Rust.

  • View the source for close in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Graphics forms
  • TCP forms
  • Additional workflows
  • Examples
  • Close the current figure
  • Close all figures
  • Close a loopback TCP client
  • Using close with coding agents
  • FAQ
  • Source you can read
  • About RunMat