Fix bug where some filters wouldn't close files