closing resources in exception