As jholland states, you can add exception handling around the call statement using try/catch syntax so that you can close the file before the exception is passed back to the main program. In this scenario where you have a multi-threaded web application where all the programs and threads are writing to the same log file it might be a good idea to implement an open-->write-->close approach for each message being written so that the file is not kept in an open extend state.
Are you performing your COBOL programs within a RunUnit created by the C# .aspx program?