better cleanup handling in signal handlers

- timeout in cleanup code preventing deadlocks
- cleanup on alarm too
- only remove copied script if it was actually copied before

tags: relevant