Add test for #39

This is a test for #39 which leads to a fatal error. Closing a file handle is one of the ways to get an unknown resource.