Close handles; More explicit error messages