Diffusion in a finite system with a moving boundary