Fix assertion failure when removing a note plugin while a session is weak-refed