In the movie Jack has the ability to “Shine” and therefore he's able to supernaturally move objects. Charles Grady is a real person, who worked in The Overlook in 1970, but the other one Delbert Grady is a product of Jack’s mind and as he speaks to him in the storeroom he’s really talking to himself. But it’s his power to “Shine”, that’s so well hidden in the movie, which enables him to unlock the storeroom door and get out by himself.
Click here and read more about Jack’s ability to “Shine”।
In the novel a ghost does let out Jack out of the storeroom. But this is another obvious reversal Stanley Kubrick made from the novel as he turned it inside out.