add listeners to documents that are open and remove them on close