Cleaned up a possible memory leak at exit