The BEAM will close the file when the process that opened it exits - unless the exit is abnormal. ^c is an a abnormal exit so if you’re test in exs and thats how you exit then I think the error is to be expected.
Front the docs:
A file must be opened and closed. If a file has not been properly closed, the dets module will automatically repair the file. This might take some time if the file is very large. By default, files are closed if the process which opened the file terminates. If several Erlang processes open the same dets file, they will all share the file. The file is properly closed when all users has either terminated or closed the file. dets files are not properly closed if the Erlang runtime system is terminated abnormally.