Closing resources correctly.