Make thread handling a little safer:
- Barcode reader stops trying after 5 seconds
- Exit handler checks whether thread is running and kills it
- Handler functions kill barcode reader thread