Updated close function to expect two arguments