added close popup functionality and optional callback