Fixes runtime error of close function.