Add function to remove listeners

Deleting objects without removing their references in other
object was causing segmentation faults terminating the program.

Therefore, a function was added to remove listeners and avoid
calling objects that no longer exist.