Fix memory leak when unregistering most recently opened file handle.