Added quit function and revised mining script

Refined scripts