How to test if a file is existing and 'closed'?

btw: That ‘tracing’ triggered my question here: Testing GC and finalizers