Shell corrections of the finite deformed Woods-Saxon potential are calculat
ed using the Green's function method and the generalized Strutinsky smoothi
ng procedure. They are compared with the results of the standard prescripti
on which are affected by the spurious contribution from the unphysical part
icle gas. In the new method, the shell correction approaches the exact limi
t provided that the dimension of the single-particle (harmonic oscillator)
basis is sufficiently large. For spherical potentials, the present method i
s faster than the exact one in which the contribution from the particle con
tinuum states is explicitly calculated. For deformed potentials, the Green'
s function method offers a practical and reliable way of calculating shell
corrections for weakly bound nuclei.