The Canterville Ghost
(1944)

In medieval England, Sir Simon of Canterville (Charles Laughton) is supposed to fight a duel to defend his family honor.  He hides in a closet.  His father is furious that Simon's cowardice is ruining the family honor.  The father has the closet bricked shut, leaving Simon to die inside.

Centuries later, in 1943, Simon is the most famous ghost in England.  He has haunted the family castle for centuries.  He can not rest in peace, until a descendant has performed an act of great bravery.  A group of american soldiers are stationed in the castle during WWII.  The soldiers torment and harass the poor ghost.  They discover that one of the soldiers, Cuffy (Robert Young) is a descendant of Simon.  Lady Jessica, the current owner of the castle, and Simon try to help Cuffy perform a heroic act to free Simon.  Cuffy is as much of a coward as all his ancestors, and fails to do anything brave.  Cuffy is going to be transferred out of the unit.

A german bomb is dropped near the castle.  The bomb does not explode, but Cuffy hears its timer mechanism ticking down.  There is no time empty the castle.  Cuffy hooks the bomb to his jeep, drags it away and dumps it where it can safely explode without injuring anyone.  Cuffy's brave act frees Simon from being a ghost.

Thanks Joseph C!