scripting: first check if we are still loaded before we try to remove ourselves

Signed-off-by: Ruben Smits <ruben.smits@intermodalics.eu>