use custom close function