Fixed a resource leak in main runner