Yes, the file will be automatically closed when the process terminates, regardless of the reason for the process termination.
This is documented in POSIX. In “Consequences of Process Termination”, among other consequences:
- All of the file descriptors, directory streams, conversion descriptors, and message catalog descriptors open in the calling process shall be closed.
And in “Terminating a Process”:
It is important that the consequences of process termination as described occur regardless of whether the process called _exit() (perhaps indirectly through exit()) or instead was terminated due to a signal or for some other reason.