Fix onRemoved function in background script