Change this to `end` of the block form of `File.open` block that should start on https://github.com/wchen-r7/metasploit-framework/blob/1350cd5a81da9abf137bb394471172e7b376166f/modules/auxiliary/client/smtp/emailer.rb#L51, which will protect from any VM errors from other threads occurring between line 51 and 76.