Closing javascript function