Not sure what you're asking here. Usually the semantics behind what happens to an unused variable (i.e. is the file automatically closed, etc.) come down to how the language is designed. It could be automatically destroyed (like RAII in C++) or it could just be forgotten.
In a purely functional language with affine types, unused variables are usually just optimized out.
In a purely functional language with affine types, unused variables are usually just optimized out.