Generally speaking, yes, you can immediately deduct the non depreciated value. Most machines will be scraped, giving them a "scrape value". You would immediately deduct the difference.
In fact, sometimes when you dispose of an asset, you get more for the scrape than you have left in depreciation- and you have to take that difference as a profit.