Refund unused resources if refining/mining cannot be completed.

Fixes some inequality bugs introduced by the first attempt, and refunds all of the unused resources instead of just the megajoules. Also updates the appropriate status display variables.