It seems that MidiFile::writeTrack ignores any endOfTrack metaEvent present in the midisequence when writing it to the file. Instead it adds it's own endOfTrackMetaEvent after the last event in the sequence.
While it might seem to be a good idea to ascertain that the mandatory endOfTrack event is added to the file if it has been forgotten, the problem is that it's timestamp is that of the event before. This not only makes it hard to store an empty, silent midi file (for later editing), it also makes it hard to keep any trailing silence in the file. You can't just put a couple of equidistant notes in the file and then loop it because there will be no pause between the last note and the first note in the next loop.
So, if there's no law against having a space before the endoftrack event, why not let writeTrack keep the timestamp of said event if it's already present in the sequence when writing it to the file?