# File Auto-Close Behavior > [HTML Version](file_auto-close_behavior.htm) _Created July 2015_ Revisions to file auto-close behavior with respect to SBXs: • ASQL connections are auto-disconnected using the same set of rules used for the auto-closing of normal files. • By default, files and ASQL connections are auto-closed only when a RUN file terminates—i.e. not on return from an SBX. • If the AF\_SBXASRUN flag in Xcall [ASFLAG](asflagsbr.htm.md) is set at the time a file is opened within an SBX, that file will be auto-closed (or auto-disconnected for ASQL) when the SBX returns. Note that while this behavior is intended as a convenience for unexpected aborts within an SBX, auto-disconnecting an ASQL connection does not auto-close the ASQL library itself. That probably won't matter to the application, but may prevent the library from being unloaded until the A-Shell process finally terminates. • In a nested SBX call (where an SBX calls another SBX), if the AF\_SBXASRUN flag is clear when the file is opened, then it will be auto-closed or auto-disconnected on return from the last SBX that was called with the flag set. For example, if A.RUN XCALLs B.SBX, which sets the AF\_SBXASRUN flag and XCALLs C.SBX, which clears it, then any files subseuqently opened in C.SBX will be closed when B.SBX (not C.SBX) returns. **History** 2015 March, A-Shell 6.1.1405: Add feature to A-Shell