Updated thread_exit to close files with interrupts on